/******************************************************************************
 * * interphone_main.c - implementation of framework main functions
 *
 * *(C) Copyright 2019 Asr International Ltd.
 * * All Rights Reserved
 * ******************************************************************************/

/*********************
*      INCLUDES
*********************/
#include "interphone_global.h"
#include "ui_app_mng.h"
#include <time.h>
#include "lv_drv_conf.h"

#ifdef USE_LV_INTERPHONE_DEMO

#if USE_LV_INTERPHONE_TEST
#include "app_adaptor_interface.h"
#include "inter_setting_interface.h"
#include "inter_modemadp_interface.h"
#include "../../framework/message/phone_msg_handle.h"
#include "utility.h"
extern TASK_HANDLE *gui_task_id;

#define INTERPHONE_TEST_NV_HANDSET_OFFSET  0 // CALL_NV_HANDSET_OFFSET
#define INTERPHONE_TEST_NV_SPEAKER_OFFSET  1 // CALL_NV_SPEAKER_OFFSET

typedef struct
{
    BOOL  IsMt;
    UINT8 RingVol;
    INT32 CallIndex;
} Interphone_Test_Call_Info_t;

#endif

/**********************
*    FUNCTIONS
**********************/
VOID Interphone_Create_Login(VOID);
VOID Interphone_Create_GroupList(VOID);
VOID Interphone_Create_Setting(ACTIVITY_ID ScrId);
VOID Interphone_Create_GroupMemberList(UINT8 Index);
VOID Interphone_Create_FriendList(VOID);
VOID Interphone_Create_QuitOpt(VOID);
#if USE_CRANE_CAMERA
VOID Interphone_Create_Camera(VOID);
#endif
VOID Interphone_Create_PowerOff(ACTIVITY_ID SrcId);
VOID Interphone_GroupList_Init(VOID);
VOID Interphone_FriendList_Init(VOID);
static VOID Interphone_Set_StatusBar_Online_Hidden(BOOL Hidden, BOOL Online, UINT32 Timeout);

extern INT8 *Framework_Get_Battery_Symbol(UINT8 BatSta);
extern UINT8 Framework_Get_Battery_Level(UINT8 Bat);
extern INT8 *Framework_Signal_Bar_To_Symbol(MMI_MODEM_SIGNAL_BAR Bar);
#if USE_LV_INTERPHONE_TEST
static VOID Interphone_Create_Test(VOID);
#endif

extern VOID Framework_Set_Phone_Ready_Status(BOOL PhoneReady);

/**********************
*  STATIC VARIABLES
**********************/
static lv_ll_t                 *Interphone_GroupList  = NULL;
static lv_ll_t                 *Interphone_FriendList = NULL;
static Interphone_Status_Bar_t g_Interphone_StatusBar;
static BOOL                    g_Interphone_LcdStatus = TRUE;
static UINT32                  g_Interphone_BLTimer   = 0;
static BOOL                    g_PoweroffLongPress    = FALSE;
static TIMER_ID                g_LoggingOutTimer      = NULL;
static BOOL                    g_SimSta               = FALSE;

// for test
static UINT8                SliderVolume = 6;
static lv_obj_t             *SliderCont  = NULL;
static UINT8                BackLight    = 3;

Interphone_GroupMember_Info TestMember[] =
{
    { "ASRTest001", TRUE  },
    { "ASRTest003", TRUE  },
    { "ASRTest004", TRUE  },
    { "ASRTest002", FALSE },
    { "ASRTest005", FALSE },
    { "ASRTest006", FALSE },
    { "ASRTest007", FALSE },
    { "ASRTest008", FALSE },
};

Interphone_GroupList_Info TestGroup[] =
{
    { "ASR0", 4, 1, 0, &TestMember[0] },
    { "ASR1", 3, 0, 0, &TestMember[1] },
    { "ASR2", 5, 3, 0, &TestMember[2] },
    { "ASR3", 7, 4, 0, &TestMember[3] },
    { "ASR4", 6, 0, 0, &TestMember[4] },
};

Interphone_FriendList_Info TestFriend[] =
{
    { "Friend001", TRUE  },
    { "Friend002", TRUE  },
    { "Friend003", TRUE  },
    { "Friend004", FALSE },
    { "Friend005", FALSE },
};

#if USE_LV_INTERPHONE_TEST
static BOOL g_SpkOn = TRUE;
static VOID *g_ReservedDesc = NULL;
#endif

/**********************
*  STATIC FUNCTIONS
**********************/
static VOID Interphone_Set_Lcd_Status(BOOL Wakeup)
{
    printf("%s: wakup %d\n", __FUNCTION__, Wakeup);
    if (Wakeup == g_Interphone_LcdStatus)
    {
        return;
    }

    g_Interphone_LcdStatus = Wakeup;
    if (Wakeup)
    {
        Hal_Lcd_Wakeup();
    }
    else
    {
        Hal_Lcd_Sleep();
    }
}


static VOID Interphone_Update_StatusBar(VOID)
{
    hal_rtc_t TimeAndDate;
    INT8      TimeStr[12];

    // update plmn rat
    INT8 Operator[MMI_MAX_PLMN_NAME_LEN + 1];
    MMI_MODEM_PLMN_RAT Rat;
    MMI_Modem_Get_Operator_Req(MMI_MODEM_SIM_1, Operator, &Rat);
    if (g_SimSta && g_Interphone_StatusBar.Label_Stan)
    {
        if (MMI_MODEM_PLMN_RAT_LTE == Rat)
        {
            lv_label_set_text(g_Interphone_StatusBar.Label_Stan, "4G");
        }
        else if (MMI_MODEM_PLMN_RAT_UMTS == Rat)
        {
            lv_label_set_text(g_Interphone_StatusBar.Label_Stan, "3G");
        }
        else if (MMI_MODEM_PLMN_RAT_GSM == Rat)
        {
            lv_label_set_text(g_Interphone_StatusBar.Label_Stan, "2G");
        }
        else
        {
            lv_label_set_text(g_Interphone_StatusBar.Label_Stan, "");
        }
        lv_obj_align(g_Interphone_StatusBar.Label_Stan, g_Interphone_StatusBar.Img_Signal,
                     LV_ALIGN_OUT_LEFT_MID, 0, 0);
        lv_obj_align(g_Interphone_StatusBar.Label_Volume, g_Interphone_StatusBar.Label_Stan,
                     LV_ALIGN_OUT_LEFT_MID, 0, 0);
    }

    // update time
    Hal_Rtc_Gettime(&TimeAndDate);
    snprintf(TimeStr, 12, "%02d:%02d", TimeAndDate.tm_hour, TimeAndDate.tm_min);
    lv_label_set_text(g_Interphone_StatusBar.Label_Time, TimeStr);

    // update signal
    MMI_MODEM_SIGNAL_BAR Signal = MMI_Modem_Get_Signal_Bar_Req(MMI_MODEM_SIM_1);
    lv_img_set_src(g_Interphone_StatusBar.Img_Signal, Framework_Signal_Bar_To_Symbol(Signal));

    // update battery
    HAL_CHG_STATUS ChaSta = Hal_Charger_Get_Status();
    if (ChaSta == HAL_CHG_DISCONNECTED)
    {
        UINT8 BatSta = Framework_Get_Battery_Level(Hal_Battery_Get_Status());
        lv_label_set_text(g_Interphone_StatusBar.Label_Battery,
            Framework_Get_Battery_Symbol(BatSta));
    }
    else if (ChaSta == HAL_CHG_CONNECTED)
    {
        lv_label_set_text(g_Interphone_StatusBar.Label_Battery, LV_SYMBOL_CHARGE);
    }
}


static VOID Interphone_Suspend(VOID)
{
    UINT32 WakeupFlag = 0;

    Interphone_Set_Lcd_Status(FALSE);
    WakeupFlag = Hal_Pm_Suspend();         /*suspend gui task*/
    printf("%s: wakeupflag %d\n", __FUNCTION__, WakeupFlag);
    Hal_Pm_Resume();
    if ((PM_RESUME_NORMALKEY & WakeupFlag)
        || (PM_RESUME_ENDKEY & WakeupFlag))
    {
        UI_Wake_Up_With_Key();
    }
    g_Interphone_BLTimer = 0;
    Interphone_Update_StatusBar();
    Interphone_Set_Lcd_Status(TRUE);
}


static VOID Interphone_Status_Update_Timer_Cb(VOID *param)
{
    UINT32 BacklightPeriod = 60;

    if (FALSE == g_Interphone_LcdStatus)
    {
        return;
    }

    if (1000 >= lv_disp_get_inactive_time(NULL))
    {
        g_Interphone_BLTimer = 0;
    }
    else
    {
        g_Interphone_BLTimer++;
    }

    if (BacklightPeriod <= g_Interphone_BLTimer)
    {
        Interphone_Suspend();
    }
    else
    {
        Interphone_Update_StatusBar();
    }
}


static VOID Interphone_Volume_Slider_Cb(lv_anim_t *Anim)
{
    lv_obj_del(SliderCont);
    SliderCont = NULL;
}


static VOID Interphone_Update_Volume_Status(VOID)
{
    if (SliderVolume == 0)
    {
        lv_label_set_text(g_Interphone_StatusBar.Label_Volume, LV_SYMBOL_MUTE);
    }
    else
    {
        lv_label_set_text(g_Interphone_StatusBar.Label_Volume, "");
    }
    if (g_Interphone_StatusBar.Label_Stan)
    {
        lv_obj_align(g_Interphone_StatusBar.Label_Volume, g_Interphone_StatusBar.Label_Stan,
                     LV_ALIGN_OUT_LEFT_MID, 0, 0);
    }
    else if (g_Interphone_StatusBar.Img_Stan)
    {
        lv_obj_align(g_Interphone_StatusBar.Label_Volume, g_Interphone_StatusBar.Img_Stan,
                     LV_ALIGN_OUT_LEFT_MID, 0, 0);
    }
}


static VOID Interphone_Set_Volume_Slider_Value(UI_KEY_VALUE Key_Val)
{
    if (KEY_LEFT == Key_Val)
    {
        if (SliderVolume > 0)
        {
            SliderVolume = SliderVolume - 1;
        }
        else
        {
            SliderVolume = 0;
        }
    }
    else if (KEY_RIGHT == Key_Val)
    {
        if (SliderVolume < 10)
        {
            SliderVolume = SliderVolume + 1;
        }
        else
        {
            SliderVolume = 10;
        }
    }
    if (SliderCont)
    {
        lv_obj_t *slider = lv_obj_get_child(SliderCont, NULL);
        lv_slider_set_value(slider, SliderVolume, LV_ANIM_OFF);
        lv_anim_del(SliderCont, NULL);
    }
    else
    {
        SliderCont = UI_Volume_Slider_Create(SliderVolume);
    }
    lv_anim_t a = {};
    lv_anim_init(&a);
    lv_anim_set_var(&a, SliderCont);
    lv_anim_set_time(&a, 2000);
    lv_anim_set_ready_cb(&a, Interphone_Volume_Slider_Cb);
    lv_anim_start(&a);

    Interphone_Update_Volume_Status();
} /* Interphone_Set_Volume_Slider_Value */


static VOID Interphone_StatusBar_Timer_Cb(VOID *param)
{
    Interphone_Set_StatusBar_Online_Hidden(TRUE, TRUE, 0);
}


static VOID Interphone_Set_StatusBar_Online_Hidden(BOOL Hidden, BOOL Online, UINT32 Timeout)
{
    lv_obj_set_hidden(g_Interphone_StatusBar.Label_Time, !Hidden);
    lv_obj_set_hidden(g_Interphone_StatusBar.Label_Battery, !Hidden);
    lv_obj_set_hidden(g_Interphone_StatusBar.Img_Signal, !Hidden);
    if (g_Interphone_StatusBar.Label_Stan)
    {
        lv_obj_set_hidden(g_Interphone_StatusBar.Label_Stan, !Hidden);
    }
    if (g_Interphone_StatusBar.Img_Stan)
    {
        lv_obj_set_hidden(g_Interphone_StatusBar.Img_Stan, !Hidden);
    }
    lv_obj_set_hidden(g_Interphone_StatusBar.Label_Volume, !Hidden);
    lv_obj_set_hidden(g_Interphone_StatusBar.Label_Online, Hidden);
    if (Timeout > 0)
    {
        if (Online)
        {
            lv_label_set_text_id(g_Interphone_StatusBar.Label_Online, PHONE_TEXT_ID_ONLINE);
        }
        else
        {
            lv_label_set_text_id(g_Interphone_StatusBar.Label_Online, PHONE_TEXT_ID_OFFLINE);
        }

        Hal_Timer_Start(Timeout, Interphone_StatusBar_Timer_Cb, NULL, FALSE);
    }
}


static VOID Interphone_Logging_Timer_Cb(VOID *param)
{
    lv_obj_del((lv_obj_t *)param);
    Interphone_Create_GroupList();
    Interphone_Set_StatusBar_Online_Hidden(FALSE, TRUE, 1000);
}


static VOID Interphone_Quit_Timer_Cb(VOID *param)
{
    lv_obj_del((lv_obj_t *)param);
    Nav_Forward(ACT_ID_ANY, ACT_ID_WT_LOGIN, NULL, NULL);
    Interphone_Set_StatusBar_Online_Hidden(FALSE, FALSE, 1000);
    Hal_Timer_Start(1000, Interphone_StatusBar_Timer_Cb, NULL, FALSE);
    g_LoggingOutTimer = NULL;
}


/**
 * Action if pressing selected item btn in group member list interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_GroupMemberList_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        lv_obj_t *CbImg = lv_obj_get_child(Btn, NULL);

        if (UI_Get_User_Num(CbImg) == 10)
        {
            lv_img_set_src(CbImg, SYMBOL_INTERPHONE_CHECK);
            UI_Set_User_Num(CbImg, 11);
        }
        else
        {
            lv_img_set_src(CbImg, SYMBOL_INTERPHONE_UNCHECK);
            UI_Set_User_Num(CbImg, 10);
        }
    }
}


/**
 * Action if pressing setting switch item btn in setting interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID InterPhone_Setting_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        lv_obj_t *SpeedLabel;
        lv_obj_t *Cont = UI_Setting_Get_Sw_Cont(Btn);
        if (NULL == Cont) return;
        lv_obj_t *sw = lv_obj_get_child(Cont, NULL);

        if (lv_switch_get_state(sw))
        {
            lv_switch_off(sw, LV_ANIM_OFF);
            if (UI_Get_User_Num(Btn) == PHONE_TEXT_ID_SHOW_SPEED)
            {
                SpeedLabel = lv_obj_get_child(Btn, NULL);
                if (SpeedLabel)
                {
                    lv_obj_del(SpeedLabel);
                }
            }
        }
        else
        {
            lv_switch_on(sw, LV_ANIM_OFF);
            if (UI_Get_User_Num(Btn) == PHONE_TEXT_ID_SHOW_SPEED)
            {
                SpeedLabel = UI_Create_NetSpeed_Label(Btn, 0.2, 1.5);
            }
        }
    }
}


/**
 * Action if pressing quit btn in setting interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID InterPhone_Setting_Quit_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Interphone_Create_QuitOpt();
    }
}


#if USE_LV_INTERPHONE_TEST
/**
 * Action if pressing test btn in setting interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID InterPhone_Setting_Test_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Interphone_Create_Test();
    }
}
#endif


#if USE_CRANE_CAMERA
/**
 * Action if pressing camera preview btn in setting interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID InterPhone_Setting_Camera_Preview_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Interphone_Create_Camera();
    }
}
#endif


/**
 * Action if pressing opratoropt btn in login interface
 * param (in) Btn: lv_obj_t *
 * return void
 */
static VOID Interphone_OpratorOpt_Btn_Action(lv_obj_t *Btn)
{
    lv_obj_t *OperList = UI_OperatorList_Create(Btn);
    INT8     OptStr[64];

    snprintf(OptStr, 64, "%s\n%s\n%s", (INT8 *)lv_lang_get_text(
                 PHONE_TEXT_ID_CTCC), (INT8 *)lv_lang_get_text(PHONE_TEXT_ID_CMCC),
             (INT8 *)lv_lang_get_text(PHONE_TEXT_ID_CUCC));
    lv_dropdown_set_options(OperList, OptStr);
    lv_dropdown_open(OperList);
    lv_dropdown_ext_t * ext = lv_obj_get_ext_attr(OperList);
    lv_obj_align(ext->page, Btn, LV_ALIGN_OUT_BOTTOM_RIGHT, -20, 0);
}


/**
 * Action if pressing login btn in login interface
 * param (in) Btn: blv_obj_t *
 * return void
 */
static VOID Interphone_Login_Btn_Action(lv_obj_t *Btn)
{
    lv_obj_t *cont = UI_TipMsg_Create((INT8 *)lv_lang_get_text(PHONE_TEXT_ID_LOGING_IN));
    Hal_Timer_Start(1000, Interphone_Logging_Timer_Cb, (VOID *)cont, FALSE);
}


/**
 * Action if pressing Friendlist button on GroupList interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_FriendList_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Interphone_Create_FriendList();
    }
}


/**
 * Action if pressing one group button on GroupList interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_GroupList_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        UINT8 Index = UI_Get_User_Num(Btn);

        Interphone_Create_GroupMemberList(Index);
    }
}


/**
 * Action if pressing quit button on quit option interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_QuitOpt_Quit_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        lv_obj_t *cont = UI_TipMsg_Create((INT8 *)lv_lang_get_text(PHONE_TEXT_ID_EXITING));

        g_LoggingOutTimer = Hal_Timer_Start(1000, Interphone_Quit_Timer_Cb, (VOID *)cont, FALSE);
    }
}


/**
 * Action if pressing logout button on quit option interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_QuitOpt_Logout_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        lv_obj_t *cont = UI_TipMsg_Create((INT8 *)lv_lang_get_text(PHONE_TEXT_ID_LOGGING_OUT));

        g_LoggingOutTimer = Hal_Timer_Start(1000, Interphone_Quit_Timer_Cb, (VOID *)cont, FALSE);
    }
}


/**
 * Action if pressing poweroff button on poweroff interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_PowerOff_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Framework_Set_Phone_Ready_Status(FALSE);
        Hal_Power_Off(HAL_TYPE_POWER_OFF);
    }
}


/**
 * Action if pressing restart button on poweroff interface
 * param (in) Btn: lv_obj_t *
 * param (in) Event: lv_event_t
 * return void
 */
static VOID Interphone_Restart_Btn_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED == Event)
    {
        Framework_Set_Phone_Ready_Status(FALSE);
        Hal_Power_Off(HAL_TYPE_REBOOT);
    }
}


/**
 * Callback function for handling key pressed on poweroff interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_PowerOff_KeyCb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_WT_POWEROFF);
            Ret = 1;
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
        {
            if (g_PoweroffLongPress)
            {
                g_PoweroffLongPress = FALSE;
            }
            else
            {
                if (strcmp(UI_Get_User_Ptr(lv_list_get_btn_selected(Obj)), "poweroff") == 0)
                {
                    Framework_Set_Phone_Ready_Status(FALSE);
                    Hal_Power_Off(HAL_TYPE_POWER_OFF);
                }
                else
                {
                    Framework_Set_Phone_Ready_Status(FALSE);
                    Hal_Power_Off(HAL_TYPE_REBOOT);
                }
            }
            Ret = 1;
            break;
        }

        default:
            break;
        }
    }

    return(Ret);
} /* Interphone_PowerOff_KeyCb */


/**
 * Callback function for handling key pressed on quit option interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_QuitOpt_KeyCb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;

    if (g_LoggingOutTimer)
    {
        Ret = 1;
        return(Ret);
    }

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_UP:
            lv_group_focus_prev(lv_obj_get_group(Obj));
            Ret = 1;
            break;

        case KEY_DOWN:
            lv_group_focus_next(lv_obj_get_group(Obj));
            Ret = 1;
            break;

        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_WT_QUIT_OPT);
            Ret = 1;
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        case LV_KEY_ENTER:
            lv_event_send(Obj, LV_EVENT_CLICKED, NULL);
            Ret = 1;
            break;

        default:
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_QUIT_OPT);
            Ret = 1;
        }
    }

    return(Ret);
} /* Interphone_QuitOpt_KeyCb */


/**
 * Callback function for handling key pressed on friendlist interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 InterPhone_Friendlist_KeyCb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_WT_FRIEND_LIST);
            Ret = 1;
            break;

        case KEY_DIAL:
            Interphone_Create_Setting(ACT_ID_WT_FRIEND_LIST);
            Ret = 1;
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        default:
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_FRIEND_LIST);
            Ret = 1;
        }
    }

    return(Ret);
} /* InterPhone_Friendlist_KeyCb */


/**
 * Callback function for handling key pressed on setting interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 InterPhone_Settings_KeyCb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;
    lv_obj_t * SelBtn = lv_list_get_btn_selected(Obj);
    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_WT_SETTING);
            Ret = 1;
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        case KEY_UP:
            if (lv_list_get_prev_btn(Obj, lv_list_get_prev_btn(Obj, SelBtn)) == NULL)
            {
                lv_list_focus_btn(Obj, lv_list_get_next_btn(Obj, NULL));
            }
            break;

        case KEY_DOWN:
            if (lv_list_get_next_btn(Obj, SelBtn) == NULL)
            {
                lv_list_focus_btn(Obj, lv_list_get_next_btn(Obj, NULL));
            }
            break;
        case KEY_OK:
            if(lv_list_get_btn_index(Obj, SelBtn) == 10)
            {
                lv_obj_t * Bar = lv_obj_get_child(SelBtn, NULL);
                UINT8 Value = lv_bar_get_value(Bar);
                if(Value == lv_bar_get_max_value(Bar))
                    BackLight = 1;
                else
                    BackLight = Value + 1;
                lv_bar_set_value(Bar, BackLight, LV_ANIM_OFF);
                Hal_Backlight_Intensity_Set((HAL_INTENSITY_LEVEL)BackLight);
                Ret = 1;
            }
            break;
        default:
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_SETTING);
            Ret = 1;
        }
    }

    return(Ret);
}


/**
 * Callback function for handling key pressed on groupmember interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_GroupMember_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta,
    UI_KEY_VALUE Key_Val)
{
    UINT8           Ret   = 0;
    static lv_obj_t *cont = NULL;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_WT_GROUPMEMBER_LIST);
            Ret = 1;
            break;

        case KEY_DIAL:
            Interphone_Create_Setting(ACT_ID_WT_GROUPMEMBER_LIST);
            Ret = 1;
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_SOFTLEFT:
        {
            if (cont)
            {
                lv_obj_del(cont);
            }
            Ret = 1;
            break;
        }

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        default:
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_GROUPMEMBER_LIST);
            Ret = 1;
        }
        else if (KEY_SOFTLEFT == Key_Val)
        {
            cont = UI_TipMsg_Create((INT8 *)lv_lang_get_text(PHONE_TEXT_ID_TALKING));
            Ret  = 1;
        }
    }

    return(Ret);
} /* Interphone_GroupMember_Key_Cb */


/**
 * Callback function for handling key pressed on grouplist interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_GroupList_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8           Ret   = 0;
    static lv_obj_t *cont = NULL;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_DIAL:
            Interphone_Create_Setting(ACT_ID_WT_GROUP_LIST);
            Ret = 1;
            break;

        case KEY_SOFTLEFT:
        {
            if (cont)
            {
                lv_obj_del(cont);
            }
            Ret = 1;
        }
        break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        default:
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_GROUP_LIST);
            Ret = 1;
        }
        else if (KEY_SOFTLEFT == Key_Val)
        {
            cont = UI_TipMsg_Create((INT8 *)lv_lang_get_text(PHONE_TEXT_ID_TALKING));
            Ret  = 1;
        }
    }

    return(Ret);
} /* Interphone_GroupList_Key_Cb */


/**
 * Callback function for handling key pressed on login interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_Login_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_UP:
            if (UI_Get_User_Num(Obj) != 100)
            {
                lv_group_focus_prev(lv_obj_get_group(Obj));
                Ret = 1;
            }
            break;

        case KEY_DOWN:
            if (UI_Get_User_Num(Obj) != 100)
            {
                lv_group_focus_next(lv_obj_get_group(Obj));
                Ret = 1;
            }
            break;

        case KEY_OK:
            if (UI_Get_User_Num(Obj) == 100)
            {
                lv_dropdown_ext_t *ext = lv_obj_get_ext_attr(Obj);
                if (ext->page)
                {
                    ext->sel_opt_id_orig = ext->sel_opt_id;
                    UI_OperatorList_Action(Obj, LV_EVENT_CLICKED);
                }
                Ret = 1;
            }
            else if (UI_Get_User_Num(Obj) == 50)
            {
                Interphone_OpratorOpt_Btn_Action(Obj);
            }
            else if (UI_Get_User_Num(Obj) == 51)
            {
                Interphone_Login_Btn_Action(Obj);
            }
            break;

        case KEY_SOFTRIGHT:
            if (UI_Get_User_Num(Obj) == 100)
            {
                lv_group_focus_next(lv_obj_get_group(Obj));
                lv_group_remove_obj(Obj);
                lv_obj_del(Obj);
                UI_Login_Reset_FocusFunc();
                Ret = 1;
            }
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Set_Volume_Slider_Value(Key_Val);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;

        default:
            break;
        } /* switch */
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_WT_LOGIN);
            Ret = 1;
        }
    }

    return(Ret);
} /* Interphone_Login_Key_Cb */


/**
 * Callback function for additional actions after Creating login interface
 * param (in) Ctrl: VOID *
 * return  VOID
 */
static VOID Interphone_Login_OnCreate(VOID *Ctrl)
{
    Interphone_GroupList_Init();
    Interphone_FriendList_Init();
}


static VOID Interphone_Common_OnDestroy(VOID *Ctrl)
{
}


static VOID Interphone_Login_OnSave(VOID *Ctrl)
{
}


static VOID Interphone_Login_OnRestore(VOID *Ctrl)
{
    UI_Login_Desc_t *LoginDesc = (UI_Login_Desc_t *)Ctrl;

    lv_label_set_text(LoginDesc->Label[3].Label, "elink009");
    lv_label_set_text(LoginDesc->Label[5].Label, ". . . . . .");
    UI_Set_User_Num(LoginDesc->OperatorOpt.Button, 50);
    UI_Set_User_Num(LoginDesc->LoginBtn.Button, 51);
}


static VOID Interphone_GroupList_OnSave(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *GroupListDesc = (UI_Normal_List_Only_Desc_t *)Ctrl;

    GroupListDesc->List.Index = lv_list_get_btn_index(GroupListDesc->List.List, lv_list_get_btn_selected(
            GroupListDesc->List.List));
    printf("save index = %d\n", GroupListDesc->List.Index);
}


static VOID Interphone_GroupList_OnRestore(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *GroupListDesc = (UI_Normal_List_Only_Desc_t *)Ctrl;

    lv_label_set_text(GroupListDesc->TitleBar.Label, "ASRTest(ASR)");
}


static VOID Interphone_List_OnDestroy(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *GroupMemberDesc = (UI_Normal_List_Only_Desc_t *)Ctrl;
    UINT8                      i                = 0;

    for (i = 0; i < GroupMemberDesc->List.ListButtonCnt; i++)
    {
        if (GroupMemberDesc->List.ButtonList[i].BtnTxt)
        {
            Hal_Mem_Free(GroupMemberDesc->List.ButtonList[i].BtnTxt);
        }
    }
    Hal_Mem_Free(GroupMemberDesc->List.ButtonList);
}


static VOID Interphone_Setting_OnRestore(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *pNormalContLstDesc = (UI_Normal_Container_List_Desc_t *)Ctrl;
    UI_Container_Base_Desc_t *Desc = pNormalContLstDesc->ContList.ContainerList;
    lv_label_set_text(Desc[0].Label.Label,"ASR Test1");
    lv_label_set_text(Desc[0].u.Label2.Label, "Acc:asr001");
    for (UINT8 i = 0;i < pNormalContLstDesc->ContList.ListContainerCnt;i++)
    {
        if (PHONE_TEXT_ID_VERSION_UPDATE == Desc[i].Label.TxtId)
        {
            lv_label_set_text(Desc[i].u.Label2.Label, "1.0.0.64");
            break;
        }
    }
    uint16_t AnimTime = lv_list_get_anim_time(pNormalContLstDesc->List);
    lv_list_set_anim_time(pNormalContLstDesc->List, 0);
    lv_list_focus_btn(pNormalContLstDesc->List, Desc[pNormalContLstDesc->ContList.Index].Button);
    lv_list_set_anim_time(pNormalContLstDesc->List, AnimTime);
    lv_obj_set_y(lv_page_get_scrollable(pNormalContLstDesc->List), pNormalContLstDesc->scrl_y);
}


static VOID Interphone_Setting_OnDestroy(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Ctrl;
    Hal_Mem_Free(Desc->ContList.ContainerList);
    Hal_Mem_Free(Desc);
    UI_Normal_Set_Btn_SeletedFunc_Clean();
}


static VOID Interphone_Setting_OnSaveState(VOID *Ctrl)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Ctrl;
    Desc->ContList.Index = lv_list_get_btn_index(Desc->List, lv_list_get_btn_selected(Desc->List));
    Desc->scrl_y = lv_obj_get_y(lv_page_get_scrollable(Desc->List));
    printf("%s: selected btn index %d\n", __FUNCTION__, Desc->ContList.Index);
}


static VOID Interphone_FriendList_OnRestore(VOID *Ctrl)
{
    UI_Normal_List_Only_Desc_t *FriendListDesc = ( UI_Normal_List_Only_Desc_t *)Ctrl;
    Interphone_FriendList_Info *Node           = NULL;
    UINT8                      i               = 0;

    lv_label_set_text(FriendListDesc->TitleBar.Label, "ASRTest(Friends)");

    Node = (Interphone_FriendList_Info *)_lv_ll_get_head(Interphone_FriendList);
    for (i = 0; i < FriendListDesc->List.ListButtonCnt; i++)
    {
        if (Node->Online == FALSE)
        {
            lv_obj_add_style(lv_obj_get_child_back(FriendListDesc->List.ButtonList[i].Button,
                                                   NULL), LV_IMG_PART_MAIN, &img_light);
            lv_obj_set_style_local_image_recolor(lv_obj_get_child_back(FriendListDesc->List.ButtonList[i].Button,
                                                                       NULL), LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
        }
        Node = _lv_ll_get_next(Interphone_FriendList, Node);
    }
}


#if USE_CRANE_CAMERA
/**
 * Callback function for handling key pressed on camera interface
 * param (in) Obj: lv_obj_t *
 * param (in) Key_Sta: UI_KEY_STATUS
 * param (in) Key_Val: UI_KEY_VALUE
 * return  UINT8
 */
static UINT8 Interphone_Camera_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 0;
    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_ANY);
            Ret = 1;
            break;

        case KEY_END:
            Interphone_Suspend();
            Ret = 1;
            break;
        }
    }
    else if (KEY_LONGPRESS == Key_Sta)
    {
        if (KEY_END == Key_Val)
        {
            Interphone_Create_PowerOff(ACT_ID_CAMERA);
            Ret = 1;
        }
    }

    return(Ret);
}


static VOID Interphone_Camera_Preview_Task(lv_task_t *Task)
{
    cam_start_preview_t Params;
    UI_Camera_Desc_t    *Desc;
    lv_obj_t            *Par;

    Desc = Nav_Get_Param(ACT_ID_CAMERA);
    LV_ASSERT_MEM(Desc);

    if (!Hal_Camera_Get_On_Flag())
    {
        Par = lv_obj_get_parent(Desc->Img);
        Params.width = lv_obj_get_width(Par);
        Params.height = lv_obj_get_height(Par);
        Params.sensor_id = 0;
        if(0 > Hal_Camera_Start_Preview(&Params))
        {
            printf("%s: warning, start preview failed\n", __FUNCTION__);
            return;
        }
    }
    if (Hal_Camera_Preview((uint8_t *)(((lv_img_dsc_t *)Desc->ImgSrc)->data))) {
        lv_img_set_src(Desc->Img, Desc->ImgSrc);
    }
    lv_task_set_period(Desc->PreviewTask, 30);
}


static VOID Interphone_Camera_OnCreate(VOID *Ctrl)
{
    UI_Camera_Desc_t    *Desc = (UI_Camera_Desc_t *)Ctrl;
    lv_img_dsc_t        *Dsc;
    cam_start_preview_t Params;
    lv_obj_t            *Par = lv_obj_get_parent(Desc->Img);

    Dsc = (lv_img_dsc_t *)Hal_Mem_Alloc(sizeof(lv_img_dsc_t));
    Dsc->header.always_zero = 0;
    Dsc->header.w = lv_obj_get_width(Par);
    Dsc->header.h = lv_obj_get_height(Par);
    Dsc->data_size = Dsc->header.w * Dsc->header.h * LV_COLOR_SIZE / 8;
    Dsc->header.cf = LV_IMG_CF_TRUE_COLOR;
    Dsc->data = Hal_Mem_Alloc(Dsc->data_size);
    LV_ASSERT_MEM(Dsc->data);
    Hal_Mem_Set((VOID *)Dsc->data, 0, Dsc->data_size);
    Desc->ImgSrc = (VOID *)Dsc;
    lv_img_set_src(Desc->Img, Desc->ImgSrc);
    lv_obj_align(Desc->Img, Par, LV_ALIGN_CENTER, 0, 0);

    Params.width = Dsc->header.w;
    Params.height = Dsc->header.h;
    Params.sensor_id = 0;
    if (0 > Hal_Camera_Start_Preview(&Params))
    {
        printf("%s: warning, start preview failed\n", __FUNCTION__);
        return;
    }

    if(NULL == Desc->PreviewTask)
    {
        Desc->PreviewTask = lv_task_create(Interphone_Camera_Preview_Task, 500,
                                           LV_TASK_PRIO_HIGH, NULL);
    }
}


static VOID Interphone_Camera_OnDestroy(VOID *Ctrl)
{
    printf("%s\n", __FUNCTION__);

    UI_Camera_Desc_t *Desc = (UI_Camera_Desc_t *)Ctrl;

    Hal_Camera_Stop_Preview(0);
    Hal_Mem_Free(((lv_img_dsc_t *)Desc->ImgSrc)->data);
    Hal_Mem_Free(Desc->ImgSrc);
    Desc->ImgSrc = NULL;
    if(Desc->PreviewTask) {
        lv_task_del(Desc->PreviewTask);
        Desc->PreviewTask = NULL;
    }
}
#endif


#if USE_LV_INTERPHONE_TEST
static VOID Interphone_Test_Stop_Ring(VOID)
{
    If_Setting_Play_Tone_t *PlayToneReq;

    PlayToneReq           = Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
    PlayToneReq->SimId    = MMI_MODEM_SIM_1;
    PlayToneReq->ToneType = IF_SETTING_TONS_TYPE_CALL;
    PlayToneReq->PlayCtrl = IF_SETTING_PLAY_TONS_STOP;
    Setting_Play_Tone_Req(PlayToneReq);
}


static VOID Interphone_Test_Call_Spk_Ctrl(BOOL SpkOn)
{
    UINT32           Offset;
    HAL_CALL_SPEAKER CallSpeaker;
    UINT8            Vol = SliderVolume;

    if (SliderCont)
    {
        lv_obj_del(SliderCont);
        SliderCont = NULL;
    }
    if (SpkOn)
    {
        Offset      = INTERPHONE_TEST_NV_SPEAKER_OFFSET;
        CallSpeaker = HAL_CALL_SPK_ON;
    }
    else
    {
        Offset      = INTERPHONE_TEST_NV_HANDSET_OFFSET;
        CallSpeaker = HAL_CALL_SPK_OFF;
    }
    UI_NV_Read_Req(NV_SECTION_UI_CALL, Offset, 1, &SliderVolume);
    if (Vol != SliderVolume)
    {
        Interphone_Update_Volume_Status();
    }
    g_SpkOn = SpkOn;
    printf("%s: SpkOn %d, Vol %d\n", __FUNCTION__, SpkOn, SliderVolume);
    Hal_Call_Speaker(CallSpeaker, (HAL_SPEAKER_GAIN)SliderVolume);
}


static VOID Interphone_Test_Set_Label_Txt_Str(UI_Label_Desc_t *LabelDesc, INT8 *Txt)
{
    LabelDesc->TxtId = LV_LANG_TXT_ID_NONE;
    if (LabelDesc->ImgSrc)
    {
        Hal_Mem_Free(LabelDesc->ImgSrc);
    }
    LabelDesc->ImgSrc = Hal_Mem_Alloc(strlen(Txt) + 1);
    Hal_Mem_Copy((INT8 *)LabelDesc->ImgSrc, Txt, strlen(Txt) + 1);
    if (LabelDesc->Label)
    {
        lv_label_set_text(LabelDesc->Label, LabelDesc->ImgSrc);
    }
}


static VOID Interphone_Test_Set_Label_Txt_Id(UI_Label_Desc_t *LabelDesc, UINT16 TxtId)
{
    LabelDesc->TxtId = TxtId;
    if (LabelDesc->ImgSrc)
    {
        Hal_Mem_Free(LabelDesc->ImgSrc);
        LabelDesc->ImgSrc = NULL;
    }
    if (LabelDesc->Label)
    {
        lv_label_set_text_id(LabelDesc->Label, TxtId);
    }
}


static VOID Interphone_Test_Call_main_Back_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED != Event)
    {
        return;
    }

    Nav_Back(ACT_ID_ANY);
}


static VOID Interphone_Test_Call_Main_Answer_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED != Event)
    {
        return;
    }

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    lv_obj_del(Desc->ButtonBar.ButtonL.Button);
    Desc->ButtonBar.ButtonL.Button = NULL;
    Desc->ButtonBar.ButtonL.Valid = FALSE;

    Hal_Set_Voice_Call_Status(VOICE_CALL_START);
    MMI_Modem_Call_Request_Answer(MMI_MODEM_SIM_1);
}


static VOID Interphone_Test_Call_Main_End_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED != Event)
    {
        return;
    }

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[0].Label, PHONE_TEXT_ID_ENDING);

    Interphone_Test_Call_Info_t *Info = UI_Get_User_Ptr(Desc->TitleBar.Label);
    INT32 CallIndex = Info->CallIndex;
    if (Desc->ButtonBar.ButtonL.Valid)
    {
        lv_obj_del(Desc->ButtonBar.ButtonL.Button);
    }
    if (Desc->ButtonBar.ButtonR.Valid)
    {
        lv_obj_del(Desc->ButtonBar.ButtonR.Button);
    }
    Hal_Mem_Set(&Desc->ButtonBar, 0, sizeof(UI_Button_Bar_Desc_t));
    printf("%s: disconnect call, index %d\n", __FUNCTION__, CallIndex);
    MMI_Modem_Call_Request_Hangup(MMI_MODEM_SIM_1, CallIndex);
}


static VOID Interphone_Test_Set_Volume(UI_KEY_VALUE Key_Val, BOOL IsCall)
{
    UINT8 Volume = SliderVolume;
    BOOL SliderContFlag = (SliderCont) ? TRUE : FALSE;
    Interphone_Set_Volume_Slider_Value(Key_Val);
    if (FALSE == SliderContFlag)
    {
        lv_obj_align(SliderCont, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, -22);
    }
    printf("%s: vol %d, iscall %d\n", __FUNCTION__, SliderVolume, IsCall);
    if (SliderVolume != Volume)
    {
        if (IsCall)
        {
            if (g_SpkOn)
            {
                Hal_Call_Speaker(HAL_CALL_SPK_ON, (HAL_SPEAKER_GAIN)SliderVolume);
            }
            else
            {
                Hal_Call_Speaker(HAL_CALL_SPK_OFF, (HAL_SPEAKER_GAIN)SliderVolume);
            }
        }
        else
        {
            Setting_Set_Ring_Volume_Req((HAL_SPEAKER_GAIN)SliderVolume);
        }
    }
}


static UINT8 Interphone_Test_Call_Main_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UI_Normal_Container_List_Desc_t *Desc;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Test_Set_Volume(Key_Val, TRUE);
            break;

        case KEY_SOFTLEFT:
        case KEY_OK:
            Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_CALL_MAIN);
            if (Desc->ButtonBar.ButtonL.Valid)
            {
                Desc->ButtonBar.ButtonL.ReleaseFun(Desc->ButtonBar.ButtonL.Button, LV_EVENT_CLICKED);
            }
            break;

        case KEY_SOFTRIGHT:
        case KEY_END:
            Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_CALL_MAIN);
            if (Desc->ButtonBar.ButtonR.Valid)
            {
                Desc->ButtonBar.ButtonR.ReleaseFun(Desc->ButtonBar.ButtonR.Button, LV_EVENT_CLICKED);
            }
            break;

        default:
            break;
        }
    }

    return(1);
}


static VOID Interphone_Test_Main_Com_OnDestroy(VOID *Param)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    if (Desc->TitleBar.ImgSrc)
    {
        Hal_Mem_Free(Desc->TitleBar.ImgSrc);
    }
    for (UINT8 i = 0;i < Desc->ContList.ListContainerCnt;i++)
    {
        if (Desc->ContList.ContainerList[i].Label.ImgSrc)
        {
            Hal_Mem_Free(Desc->ContList.ContainerList[i].Label.ImgSrc);
        }
        if (UI_BASE_OBJ_TA == Desc->ContList.ContainerList[i].Choise)
        {
            if (Desc->ContList.ContainerList[i].u.Ta.TaTxt)
            {
                Hal_Mem_Free(Desc->ContList.ContainerList[i].u.Ta.TaTxt);
            }
        }
    }
    Hal_Mem_Free(Desc->ContList.ContainerList);
    Hal_Mem_Free(Desc);
}


static VOID Interphone_Test_Call_Main_OnDestroy(VOID *Param)
{
    if (SliderCont)
    {
        lv_obj_del(SliderCont);
        SliderCont = NULL;
    }
    if (g_SpkOn)
    {
        UI_NV_Write_Req(NV_SECTION_UI_CALL, INTERPHONE_TEST_NV_SPEAKER_OFFSET,
                        1, &SliderVolume);
    }
    else
    {
        UI_NV_Write_Req(NV_SECTION_UI_CALL, INTERPHONE_TEST_NV_HANDSET_OFFSET,
                        1, &SliderVolume);
    }
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    Interphone_Test_Call_Info_t *Info = UI_Get_User_Ptr(Desc->TitleBar.Label);
    printf("%s: RingVol %d\n", __FUNCTION__, Info->RingVol);
    if (Info->RingVol != SliderVolume)
    {
        SliderVolume = Info->RingVol;
        Interphone_Update_Volume_Status();
    }
    Hal_Mem_Free(Info);
    Interphone_Test_Main_Com_OnDestroy(Param);
}


static VOID Interphone_Test_Call_Main(INT8 *Number, BOOL IsMt, INT32 Index)
{
    Nav_Func_List_t                 FuncList = {};
    UI_Normal_Container_List_Desc_t *Desc;
    UINT32                          Len;
    const INT8                      Space[] = " ";

    printf("%s: IsMt %d, Number %s, Index %d, SliderVolume %d\n",
           __FUNCTION__, IsMt, Number, Index, SliderVolume);

    Desc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    Desc->TitleBar.TxtId = LV_LANG_TXT_ID_NONE;
    Desc->TitleBar.ImgSrc = Hal_Mem_Alloc(strlen(Number) + 1);
    Hal_Mem_Copy((INT8 *)Desc->TitleBar.ImgSrc, Number, strlen(Number) + 1);

    Desc->ContList.Index = 0xFF;

    Desc->ContList.ListContainerCnt = 2;
    Len = sizeof(UI_Container_Base_Desc_t) * Desc->ContList.ListContainerCnt;

    Desc->ContList.ContainerList = Hal_Mem_Alloc(Len);
    Hal_Mem_Set(Desc->ContList.ContainerList, 0, Len);

    Desc->ContList.ContainerList[0].Valid = TRUE;
    if (IsMt)
    {
        Desc->ContList.ContainerList[0].Label.TxtId  = PHONE_TEXT_ID_RINGING;
    }
    else
    {
        Desc->ContList.ContainerList[0].Label.TxtId = PHONE_TEXT_ID_CALLING;
    }
    Desc->ContList.ContainerList[0].Choise = UI_BASE_OBJ_LABEL;

    Desc->ContList.ContainerList[1].Valid = TRUE;
    Desc->ContList.ContainerList[1].Label.TxtId  = LV_LANG_TXT_ID_NONE;
    Desc->ContList.ContainerList[1].Label.ImgSrc = Hal_Mem_Alloc(strlen(Space) + 1);
    Hal_Mem_Copy((INT8 *)Desc->ContList.ContainerList[1].Label.ImgSrc, Space, strlen(Space) + 1);
    Desc->ContList.ContainerList[1].Choise = UI_BASE_OBJ_LABEL;

    if (IsMt)
    {
        Desc->ButtonBar.ButtonL.Valid      = TRUE;
        Desc->ButtonBar.ButtonL.TxtId      = PHONE_TEXT_ID_ANSWER;
        Desc->ButtonBar.ButtonL.ReleaseFun = Interphone_Test_Call_Main_Answer_Cb;
    }
    Desc->ButtonBar.ButtonR.Valid      = TRUE;
    Desc->ButtonBar.ButtonR.TxtId      = PHONE_TEXT_ID_END_CL;
    Desc->ButtonBar.ButtonR.ReleaseFun = Interphone_Test_Call_Main_End_Cb;

    Desc->KeyFunc = Interphone_Test_Call_Main_Key_Cb;

    FuncList.OnShow    = UI_Interphone_Test_Create;
    FuncList.OnDestroy = Interphone_Test_Call_Main_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CALL_MAIN, &FuncList, Desc);

    Interphone_Test_Call_Info_t *Info = Hal_Mem_Alloc(sizeof(Interphone_Test_Call_Info_t));
    Info->IsMt      = IsMt;
    Info->CallIndex = Index;
    Info->RingVol   = SliderVolume;
    UI_Set_User_Ptr(Desc->TitleBar.Label, Info);

    Interphone_Test_Call_Spk_Ctrl(TRUE);
}


static UINT8 Interphone_Test_Call_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8                           Ret = 1;
    UI_Normal_Container_List_Desc_t *Desc;
    lv_obj_t                        *Ta;
    const INT8                      *Txt;
    UINT32                          Len;
    INT8                            *Number;
    lv_obj_t                        *Label;

    if (KEY_RELEASED == Key_Sta)
    {
        Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_DIAL_MAIN);
        Ta = Desc->ContList.ContainerList[0].u.Ta.TextArea;

        switch (Key_Val)
        {
        case KEY_SOFTRIGHT: // clear & back
            if (PHONE_TEXT_ID_CLEAR == Desc->ButtonBar.ButtonR.TxtId)
            {
                lv_textarea_del_char(Ta);
                if (0 == strlen(lv_textarea_get_text(Ta)))
                {
                    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
                    Label = lv_obj_get_child_back(Desc->ButtonBar.ButtonR.Button, NULL);
                    lv_label_set_text_id(Label, Desc->ButtonBar.ButtonR.TxtId);
                }
            }
            else
            {
                Nav_Back(ACT_ID_ANY);
            }
            break;

        case KEY_END:
            Interphone_Suspend();
            break;

        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
        case KEY_HASH:
            if (KEY_ASTERISK == Key_Val)
            {
                lv_textarea_add_char(Ta, '*');
            }
            else if (KEY_HASH == Key_Val)
            {
                lv_textarea_add_char(Ta, '#');
            }
            else
            {
                lv_textarea_add_char(Ta, (INT8)(Key_Val - KEY_0 + '0'));
            }
            if (PHONE_TEXT_ID_BACK == Desc->ButtonBar.ButtonR.TxtId)
            {
                Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
                Label = lv_obj_get_child_back(Desc->ButtonBar.ButtonR.Button, NULL);
                lv_label_set_text_id(Label, Desc->ButtonBar.ButtonR.TxtId);
            }
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Test_Set_Volume(Key_Val, FALSE);
            break;

        case KEY_SOFTLEFT:
        case KEY_DIAL:
        case KEY_OK:
            Txt = lv_textarea_get_text(Ta);
            Len = strlen(Txt);
            if (0 == Len) // no number
            {
                printf("%s: no phone number\n", __FUNCTION__);
                break;
            }

            Number = Hal_Mem_Alloc(Len + 1);
            Hal_Mem_Copy(Number, Txt, Len + 1);
            Nav_Back(ACT_ID_ANY);
            Interphone_Test_Call_Main(Number, FALSE, 0);
            Hal_Set_Voice_Call_Status(VOICE_CALL_START);
            MMI_Modem_Call_Request_Dial(MMI_MODEM_SIM_1, Number, MMI_MODEM_CALL_SERVICE_NORMAL);
            break;

        default:
            break;
        } /* switch */
    }

    return(Ret);
}


static VOID Interphone_Test_Call_OnSave(VOID *Param)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    UI_Text_Area_Desc_t             *TaDesc = &Desc->ContList.ContainerList[0].u.Ta;
    if (TaDesc->TaTxt)
    {
        Hal_Mem_Free(TaDesc->TaTxt);
        TaDesc->TaTxt = NULL;
    }
    const INT8 *Txt = lv_textarea_get_text(TaDesc->TextArea);
    UINT32 Len = strlen(Txt);
    if (0 < Len)
    {
        TaDesc->TaTxt  = Hal_Mem_Alloc(Len + 1);
        Hal_Mem_Copy(TaDesc->TaTxt, Txt, Len + 1);
    }
}


static VOID Interphone_Test_Call_OnDestroy(VOID *Param)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    if (Desc->ContList.ContainerList[0].u.Ta.TaTxt)
    {
        Hal_Mem_Free(Desc->ContList.ContainerList[0].u.Ta.TaTxt);
    }
    Hal_Mem_Free(Desc->ContList.ContainerList);
    Hal_Mem_Free(Desc);
}


static VOID Interphone_Test_Call_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED != Event)
    {
        return;
    }

    printf("%s\n", __FUNCTION__);

    Nav_Func_List_t                 FuncList = {};
    UI_Normal_Container_List_Desc_t *Desc;
    UINT32                          Len;
    const INT8                      DefNum[] = "10086";

    Desc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    Desc->TitleBar.TxtId = LV_LANG_TXT_ID_NONE;

    Desc->ContList.Index = 0xFF;

    Desc->ContList.ListContainerCnt = 1;
    Len = sizeof(UI_Container_Base_Desc_t) * Desc->ContList.ListContainerCnt;

    Desc->ContList.ContainerList = Hal_Mem_Alloc(Len);
    Hal_Mem_Set(Desc->ContList.ContainerList, 0, Len);

    Desc->ContList.ContainerList[0].Valid       = TRUE;
    Desc->ContList.ContainerList[0].Label.TxtId = PHONE_TEXT_ID_PHONE_NUM;
    Desc->ContList.ContainerList[0].Choise      = UI_BASE_OBJ_TA;
    Desc->ContList.ContainerList[0].u.Ta.TaTxt  = Hal_Mem_Alloc(strlen(DefNum) + 1);
    Hal_Mem_Copy(Desc->ContList.ContainerList[0].u.Ta.TaTxt, DefNum, strlen(DefNum) + 1);

    Desc->ButtonBar.ButtonL.Valid = TRUE;
    Desc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_CALL;
    Desc->ButtonBar.ButtonR.Valid = TRUE;
    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;

    Desc->KeyFunc = Interphone_Test_Call_Key_Cb;

    FuncList.OnShow      = UI_Interphone_Test_Create;
    FuncList.OnSaveState = Interphone_Test_Call_OnSave;
    FuncList.OnDestroy   = Interphone_Test_Call_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_DIAL_MAIN, &FuncList, Desc);
}


static UINT8 Interphone_Test_Sms_Main_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Test_Set_Volume(Key_Val, FALSE);
            break;

        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_ANY);
            break;

        case KEY_END:
            Interphone_Suspend();
            break;

        default:
            break;
        }
    }

    return(1);
}


static VOID Interphone_Test_Sms_Main(INT8 *Number, INT8 *Smspdu, BOOL IsSending)
{
    Nav_Func_List_t                 FuncList = {};
    UI_Normal_Container_List_Desc_t *Desc;
    UINT32                          Len;

    printf("%s: IsSending %d, Number %s, Smspdu %s\n", __FUNCTION__, IsSending, Number, Smspdu);

    if (IsSending)
    {
        Desc = Nav_Get_Param(ACT_ID_MESSAGES_SENDING_MESSAGE);
        if (Desc)
        {
            printf("%s: sending msg ui is present\n", __FUNCTION__);
            Interphone_Test_Set_Label_Txt_Str(&Desc->TitleBar, Number);
            Interphone_Test_Set_Label_Txt_Str(&Desc->ContList.ContainerList[0].Label, Smspdu);
            if (PHONE_TEXT_ID_SENDING_FILE != Desc->ContList.ContainerList[1].Label.TxtId)
            {
                Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[1].Label,
                                                 PHONE_TEXT_ID_SENDING);
            }
            return;
        }
    }
    else
    {
        if (g_ReservedDesc)
        {
            Desc = g_ReservedDesc;
        }
        else
        {
            Desc = Nav_Get_Param(ACT_ID_MESSAGES_INBOX);
        }
        if (Desc)
        {
            printf("%s: received msg ui is present\n", __FUNCTION__);
            Interphone_Test_Set_Label_Txt_Str(&Desc->TitleBar, Number);
            Interphone_Test_Set_Label_Txt_Str(&Desc->ContList.ContainerList[0].Label, Smspdu);
            return;
        }
    }

    Desc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    Desc->TitleBar.TxtId  = LV_LANG_TXT_ID_NONE;
    Desc->TitleBar.ImgSrc = Hal_Mem_Alloc(strlen(Number) + 1);
    Hal_Mem_Copy((INT8 *)Desc->TitleBar.ImgSrc, Number, strlen(Number) + 1);

    Desc->ContList.Index = 0xFF;

    Desc->ContList.ListContainerCnt = 2;
    Len = sizeof(UI_Container_Base_Desc_t) * Desc->ContList.ListContainerCnt;

    Desc->ContList.ContainerList = Hal_Mem_Alloc(Len);
    Hal_Mem_Set(Desc->ContList.ContainerList, 0, Len);

    Desc->ContList.ContainerList[0].Valid        = TRUE;
    Desc->ContList.ContainerList[0].Label.TxtId  = LV_LANG_TXT_ID_NONE;
    Desc->ContList.ContainerList[0].Choise       = UI_BASE_OBJ_LABEL;
    Desc->ContList.ContainerList[0].Label.ImgSrc = Hal_Mem_Alloc(strlen(Smspdu) + 1);
    Hal_Mem_Copy((INT8 *)Desc->ContList.ContainerList[0].Label.ImgSrc, Smspdu, strlen(Smspdu) + 1);

    Desc->ContList.ContainerList[1].Valid = TRUE;
    if (IsSending)
    {
        Desc->ContList.ContainerList[1].Label.TxtId = PHONE_TEXT_ID_SENDING;
    }
    else
    {
        Desc->ContList.ContainerList[1].Label.TxtId  = PHONE_TEXT_ID_NEW_MSG;
    }
    Desc->ContList.ContainerList[1].Choise = UI_BASE_OBJ_LABEL;

    Desc->ButtonBar.ButtonR.Valid = TRUE;
    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    Desc->KeyFunc = Interphone_Test_Sms_Main_Key_Cb;

    FuncList.OnShow    = UI_Interphone_Test_Create;
    FuncList.OnDestroy = Interphone_Test_Main_Com_OnDestroy;

    if (IsSending)
    {
        Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_SENDING_MESSAGE, &FuncList, Desc);
    }
    else
    {
        if (Nav_Get_Param(ACT_ID_CALL_MAIN))
        {
            g_ReservedDesc = Desc;
        }
        else
        {
            Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES_INBOX, &FuncList, Desc);
        }
    }
}


#if USE_LV_WATCH_MODEM_ADAPTOR
static VOID Interphone_Sms_Send_Result_Ind(watch_app_adp_sms_send_result_type_t result)
{
    if(0 == Hal_Pm_Get_State()) Hal_Pm_WakeUp();

    printf("%s: result %d\n", __FUNCTION__, result);
    mmi_msg_send_sms_cnf_t * msg;

    msg = (mmi_msg_send_sms_cnf_t *)lv_mem_alloc(sizeof(mmi_msg_send_sms_cnf_t));

    msg->header.MsgId = MMI_MODEM_SEND_SMS_CNF;
    msg->psendsmscnf = (MMI_Modem_Send_Sms_Cnf_t *)lv_mem_alloc(sizeof(MMI_Modem_Send_Sms_Cnf_t));

    Hal_Mem_Set(msg->psendsmscnf,0,sizeof(MMI_Modem_Send_Sms_Cnf_t));

    msg->psendsmscnf->SimId = MMI_MODEM_SIM_1;
    msg->psendsmscnf->MsgIndex = 0;

    if(APP_SMS_SEND_SUCCESS == result)
    {
        msg->psendsmscnf->Result = MMI_MODEM_SMS_SUCCESS;
    }
    else
    {
        msg->psendsmscnf->Result = MMI_MODEM_SMS_FAIL;
    }

    Hal_Send_Message((TASK_ID)gui_task_id, (void *)msg);
}
#endif


static UINT8 Interphone_Test_Sms_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8                           Ret = 1;
    UI_Normal_Container_List_Desc_t *Desc;
    lv_obj_t                        *Ta;
    const INT8                      *Txt;
    UINT32                          Len;
    INT8                            *Number;
    lv_obj_t                        *Label;
    INT8                            *Smspdu;

    if (KEY_RELEASED == Key_Sta)
    {
        Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_MESSAGES);

        switch (Key_Val)
        {
        case KEY_SOFTRIGHT: // clear & back
            if (PHONE_TEXT_ID_CLEAR == Desc->ButtonBar.ButtonR.TxtId)
            {
                Ta = Desc->ContList.ContainerList[Desc->ContList.Index].u.Ta.TextArea;
                lv_textarea_del_char(Ta);
                if (0 == strlen(lv_textarea_get_text(Ta)))
                {
                    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;
                    Label = lv_obj_get_child_back(Desc->ButtonBar.ButtonR.Button, NULL);
                    lv_label_set_text_id(Label, Desc->ButtonBar.ButtonR.TxtId);
                }
            }
            else
            {
                Nav_Back(ACT_ID_ANY);
            }
            break;

        case KEY_END:
            Interphone_Suspend();
            break;

        case KEY_0:
        case KEY_1:
        case KEY_2:
        case KEY_3:
        case KEY_4:
        case KEY_5:
        case KEY_6:
        case KEY_7:
        case KEY_8:
        case KEY_9:
        case KEY_ASTERISK:
        case KEY_HASH:
            Ta = Desc->ContList.ContainerList[Desc->ContList.Index].u.Ta.TextArea;
            if (KEY_ASTERISK == Key_Val)
            {
                lv_textarea_add_char(Ta, '*');
            }
            else if (KEY_HASH == Key_Val)
            {
                lv_textarea_add_char(Ta, '#');
            }
            else
            {
                lv_textarea_add_char(Ta, (INT8)(Key_Val - KEY_0 + '0'));
            }
            if (PHONE_TEXT_ID_BACK == Desc->ButtonBar.ButtonR.TxtId)
            {
                Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;
                Label = lv_obj_get_child_back(Desc->ButtonBar.ButtonR.Button, NULL);
                lv_label_set_text_id(Label, Desc->ButtonBar.ButtonR.TxtId);
            }
            break;

        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Test_Set_Volume(Key_Val, FALSE);
            break;

        case KEY_UP:
            Desc->ContList.Index += Desc->ContList.ListContainerCnt;
            Desc->ContList.Index--;
            Desc->ContList.Index = Desc->ContList.Index % Desc->ContList.ListContainerCnt;
            lv_list_focus_btn(Desc->List, Desc->ContList.ContainerList[Desc->ContList.Index].Button);
            break;

        case KEY_DOWN:
            Desc->ContList.Index++;
            Desc->ContList.Index = Desc->ContList.Index % Desc->ContList.ListContainerCnt;
            lv_list_focus_btn(Desc->List, Desc->ContList.ContainerList[Desc->ContList.Index].Button);
            break;

        case KEY_SOFTLEFT:
        case KEY_OK:
            Ta = Desc->ContList.ContainerList[0].u.Ta.TextArea;
            Txt = lv_textarea_get_text(Ta);
            Len = strlen(Txt);
            if (0 == Len) // no number
            {
                printf("%s: no phone number\n", __FUNCTION__);
                break;
            }

            Number = Hal_Mem_Alloc(Len + 1);
            Hal_Mem_Copy(Number, Txt, Len + 1);

            Ta = Desc->ContList.ContainerList[1].u.Ta.TextArea;
            Txt = lv_textarea_get_text(Ta);
            Len = strlen(Txt);
            if (0 == Len)
            {
                printf("%s: no sms content\n", __FUNCTION__);
                break;
            }

            Smspdu = Hal_Mem_Alloc(strlen(Txt) + 1);
            Hal_Mem_Copy(Smspdu, Txt, strlen(Txt) + 1);
            Nav_Back(ACT_ID_ANY);
            Interphone_Test_Sms_Main(Number, Smspdu, TRUE);
            //MMI_Modem_Sms_File_Send_Sms_Req(Number, Smspdu, MMI_MODEM_SIM_1);
#if USE_LV_WATCH_MODEM_ADAPTOR
            app_adaptor_sms_send_req(Number, Smspdu, strlen(Smspdu), NULL,
                                     Interphone_Sms_Send_Result_Ind, MMI_MODEM_SIM_1);
#endif
            break;

        default:
            break;
        } /* switch */
    }

    return(Ret);
}


static VOID Interphone_Test_Sms_OnSave(VOID *Param)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    UI_Text_Area_Desc_t             *TaDesc;
    for (UINT8 i = 0;i < Desc->ContList.ListContainerCnt;i++)
    {
        TaDesc = &Desc->ContList.ContainerList[i].u.Ta;
        if (TaDesc->TaTxt)
        {
            Hal_Mem_Free(TaDesc->TaTxt);
            TaDesc->TaTxt = NULL;
        }
        const INT8 *Txt = lv_textarea_get_text(TaDesc->TextArea);
        UINT32 Len = strlen(Txt);
        if (0 < Len)
        {
            TaDesc->TaTxt  = Hal_Mem_Alloc(Len + 1);
            Hal_Mem_Copy(TaDesc->TaTxt, Txt, Len + 1);
        }
    }
}


static VOID Interphone_Test_Sms_OnDestroy(VOID *Param)
{
    UI_Normal_Container_List_Desc_t *Desc = (UI_Normal_Container_List_Desc_t *)Param;
    for (UINT8 i = 0;i < Desc->ContList.ListContainerCnt;i++)
    {
        if (Desc->ContList.ContainerList[i].u.Ta.TaTxt)
        {
            Hal_Mem_Free(Desc->ContList.ContainerList[i].u.Ta.TaTxt);
        }
    }
    Hal_Mem_Free(Desc->ContList.ContainerList);
    Hal_Mem_Free(Desc);
}


static VOID Interphone_Test_Sms_Cb(lv_obj_t *Btn, lv_event_t Event)
{
    if (LV_EVENT_CLICKED != Event)
    {
        return;
    }

    printf("%s\n", __FUNCTION__);

    Nav_Func_List_t                 FuncList = {};
    UI_Normal_Container_List_Desc_t *Desc;
    UINT32                          Len;
    const INT8                      DefNum[] = "10086";
    const INT8                      DefSms[] = "1234567890";

    Desc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    Desc->TitleBar.TxtId = LV_LANG_TXT_ID_NONE;

    Desc->ContList.ListContainerCnt = 2;
    Len = sizeof(UI_Container_Base_Desc_t) * Desc->ContList.ListContainerCnt;

    Desc->ContList.ContainerList = Hal_Mem_Alloc(Len);
    Hal_Mem_Set(Desc->ContList.ContainerList, 0, Len);

    Desc->ContList.ContainerList[0].Valid       = TRUE;
    Desc->ContList.ContainerList[0].Label.TxtId = PHONE_TEXT_ID_PHONE_NUM;
    Desc->ContList.ContainerList[0].Choise      = UI_BASE_OBJ_TA;
    Desc->ContList.ContainerList[0].u.Ta.TaTxt  = Hal_Mem_Alloc(strlen(DefNum) + 1);
    Hal_Mem_Copy(Desc->ContList.ContainerList[0].u.Ta.TaTxt, DefNum, strlen(DefNum) + 1);

    Desc->ContList.ContainerList[1].Valid        = TRUE;
    Desc->ContList.ContainerList[1].Label.TxtId  = PHONE_TEXT_ID_CONTENT;
    Desc->ContList.ContainerList[1].Choise       = UI_BASE_OBJ_TA;
    Desc->ContList.ContainerList[1].u.Ta.TaTxt   = Hal_Mem_Alloc(strlen(DefSms) + 1);
    Hal_Mem_Copy(Desc->ContList.ContainerList[1].u.Ta.TaTxt, DefSms, strlen(DefSms) + 1);

    Desc->ButtonBar.ButtonL.Valid = TRUE;
    Desc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_SEND;
    Desc->ButtonBar.ButtonR.Valid = TRUE;
    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_CLEAR;

    Desc->KeyFunc = Interphone_Test_Sms_Key_Cb;

    FuncList.OnShow      = UI_Interphone_Test_Create;
    FuncList.OnSaveState = Interphone_Test_Sms_OnSave;
    FuncList.OnDestroy   = Interphone_Test_Sms_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_MESSAGES, &FuncList, Desc);
}


static UINT8 Interphone_test_Key_Cb(lv_obj_t *Obj, UI_KEY_STATUS Key_Sta, UI_KEY_VALUE Key_Val)
{
    UINT8 Ret = 1; // not call default key function for List
    UI_Normal_Container_List_Desc_t *Desc;

    if (KEY_RELEASED == Key_Sta)
    {
        switch (Key_Val)
        {
        case KEY_LEFT:
        case KEY_RIGHT:
            Interphone_Test_Set_Volume(Key_Val, FALSE);
            break;

        case KEY_UP:
            Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_MENU);
            if (0 != Desc->ContList.Index)
            {
                Desc->ContList.Index--;
            }
            else
            {
                Desc->ContList.Index = Desc->ContList.ListContainerCnt - 1;
            }
            lv_list_focus_btn(Desc->List, Desc->ContList.ContainerList[Desc->ContList.Index].Button);
            Ret = 1;
            break;

        case KEY_DOWN:
            Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_MENU);
            if ((Desc->ContList.ListContainerCnt - 1) != Desc->ContList.Index)
            {
                Desc->ContList.Index++;
            }
            else
            {
                Desc->ContList.Index = 0;
            }
            lv_list_focus_btn(Desc->List, Desc->ContList.ContainerList[Desc->ContList.Index].Button);
            Ret = 1;
            break;

        case KEY_SOFTLEFT:
        case KEY_OK:
            Desc = (UI_Normal_Container_List_Desc_t *)Nav_Get_Param(ACT_ID_MENU);
            Desc->ContList.ContainerList[Desc->ContList.Index].ReleaseFunc(
                Desc->ContList.ContainerList[Desc->ContList.Index].Button, LV_EVENT_CLICKED);
            break;

        case KEY_END:
            Interphone_Suspend();
            break;

        case KEY_SOFTRIGHT:
            Nav_Back(ACT_ID_ANY);
            break;

        default:
            break;
        } /* switch */
    }

    return(Ret);
}


static VOID Interphone_Create_Test(VOID)
{
    g_SpkOn = TRUE;

    Nav_Func_List_t                 FuncList = {};
    UI_Normal_Container_List_Desc_t *Desc;
    UINT32                          Len;

    Desc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    Desc->TitleBar.TxtId = PHONE_TEXT_ID_MENU;

    Desc->ContList.ListContainerCnt = 2;
    Len = sizeof(UI_Container_Base_Desc_t) * Desc->ContList.ListContainerCnt;

    Desc->ContList.ContainerList = Hal_Mem_Alloc(Len);
    Hal_Mem_Set(Desc->ContList.ContainerList, 0, Len);

    Desc->ContList.ContainerList[0].Valid       = TRUE;
    Desc->ContList.ContainerList[0].Label.TxtId = PHONE_TEXT_ID_CALL;
    Desc->ContList.ContainerList[0].Choise      = UI_BASE_OBJ_LABEL;
    Desc->ContList.ContainerList[0].ReleaseFunc = Interphone_Test_Call_Cb;

    Desc->ContList.ContainerList[1].Valid       = TRUE;
    Desc->ContList.ContainerList[1].Label.TxtId = PHONE_TEXT_ID_SEND_SMS;
    Desc->ContList.ContainerList[1].Choise      = UI_BASE_OBJ_LABEL;
    Desc->ContList.ContainerList[1].ReleaseFunc = Interphone_Test_Sms_Cb;

    Desc->KeyFunc = Interphone_test_Key_Cb;

    Desc->ButtonBar.ButtonL.Valid = TRUE;
    Desc->ButtonBar.ButtonL.TxtId = PHONE_TEXT_ID_SELECT;
    Desc->ButtonBar.ButtonR.Valid = TRUE;
    Desc->ButtonBar.ButtonR.TxtId = PHONE_TEXT_ID_BACK;

    FuncList.OnShow = UI_Interphone_Test_Create;

    Nav_Forward(ACT_ID_ANY, ACT_ID_MENU, &FuncList, Desc);
}


static void Interphone_Test_Anim_Fp_Connected(lv_anim_t * Anim)
{
    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    if (NULL == Desc)
    {
        printf("%s: warning, no call ui\n", __FUNCTION__);
        return;
    }
    lv_obj_t *Label   = Desc->ContList.ContainerList[1].Label.Label;
    UINT32   LastTime = UI_Get_User_Num(Label);
    UINT32   CurTime  = UI_Get_Timestamp_In_Second();
    UINT32   Elaps    = CurTime - LastTime;
    UINT32   Seconds  = Elaps % 60;
    UINT32   Minutes  = Elaps / 60;
    UINT32   Hours    = Minutes / 60;
    Minutes = Minutes % 60;
    INT8 Str[10] = "";
    if(0 == Hours) {
        snprintf(Str, 10, "%.2d:%.2d", Minutes, Seconds);
    } else {
        snprintf(Str, 10, "%.2d:%.2d:%.2d", Hours, Minutes, Seconds);
    }
    lv_label_set_text(Label, Str);
}

#endif

/**********************
*  GLOBAL FUNCTIONS
**********************/
/**
 * Set SIM1 status
 * param (in) SimSta: BOOL
 * return  VOID
 */
VOID Interphone_Set_Sim_Status(BOOL SimSta)
{
    printf("%s: SIM1 status, cur %d, new %d\n", __FUNCTION__, g_SimSta, SimSta);
    if (SimSta == g_SimSta) return;

    g_SimSta = SimSta;

    if (NULL == g_Interphone_StatusBar.Img_Signal) return;

    if (TRUE == g_SimSta)
    {
        if (g_Interphone_StatusBar.Img_Stan)
        {
            lv_obj_del(g_Interphone_StatusBar.Img_Stan);
            g_Interphone_StatusBar.Img_Stan = NULL;
        }
        if (NULL == g_Interphone_StatusBar.Label_Stan)
        {
            lv_obj_t *Label = lv_label_create(lv_obj_get_parent(g_Interphone_StatusBar.Img_Signal),
                                              NULL);
            g_Interphone_StatusBar.Label_Stan = Label;
            lv_obj_set_style_local_text_color(Label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT,
                                              LV_COLOR_MAKE(0x60,0xC0,0xFF));
            lv_obj_set_style_local_text_letter_space(Label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0);
            lv_obj_set_style_local_pad_left(Label, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, 0);
            lv_label_set_text(Label, "");
            lv_obj_align(Label, g_Interphone_StatusBar.Img_Signal, LV_ALIGN_OUT_LEFT_MID, 0, 0);
            lv_obj_align(g_Interphone_StatusBar.Label_Volume, Label, LV_ALIGN_OUT_LEFT_MID, 0, 0);
        }
    }
    else
    {
        if (g_Interphone_StatusBar.Label_Stan)
        {
            lv_obj_del(g_Interphone_StatusBar.Label_Stan);
            g_Interphone_StatusBar.Label_Stan = NULL;
        }
        if (NULL == g_Interphone_StatusBar.Img_Stan)
        {
            lv_obj_t *Img = lv_img_create(lv_obj_get_parent(g_Interphone_StatusBar.Img_Signal),
                                          NULL);
            g_Interphone_StatusBar.Img_Stan = Img;
            lv_img_set_auto_size(Img, TRUE);
            lv_img_set_src(Img, SYMBOL_NO_SIM_CARD);
            lv_obj_align(Img, g_Interphone_StatusBar.Img_Signal, LV_ALIGN_OUT_LEFT_MID, 0, 0);
            lv_obj_align(g_Interphone_StatusBar.Label_Volume, Img, LV_ALIGN_OUT_LEFT_MID, 0, 0);
        }
    }
}


/**
 * Create login interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_Login(VOID)
{
    UI_Login_Desc_t *LoginDesc;
    Nav_Func_List_t FuncList;

    lv_lang_set(1);
    Hal_Backlight_Intensity_Set((HAL_INTENSITY_LEVEL)BackLight);
    LoginDesc = (UI_Login_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Login_Desc_t));
    Hal_Mem_Set(LoginDesc, 0, sizeof(UI_Login_Desc_t));

    LoginDesc->Label[0].TxtId    = PHONE_TEXT_ID_ZONE;
    LoginDesc->Label[0].TxtAlign = LV_LABEL_ALIGN_CENTER;
    LoginDesc->Label[1].TxtId    = PHONE_TEXT_ID_CTCC;
    LoginDesc->Label[1].TxtAlign = LV_LABEL_ALIGN_CENTER;
    LoginDesc->Label[2].TxtId    = PHONE_TEXT_ID_ACCOUNT;
    LoginDesc->Label[2].TxtAlign = LV_LABEL_ALIGN_CENTER;
    LoginDesc->Label[3].TxtId    = LV_LANG_TXT_ID_NONE;
    LoginDesc->Label[3].TxtAlign = LV_LABEL_ALIGN_CENTER;
    LoginDesc->Label[4].TxtId    = PHONE_TEXT_ID_PWD;
    LoginDesc->Label[4].TxtAlign = LV_LABEL_ALIGN_CENTER;
    LoginDesc->Label[5].TxtId    = LV_LANG_TXT_ID_NONE;
    LoginDesc->Label[5].TxtAlign = LV_LABEL_ALIGN_CENTER;

    LoginDesc->OperatorOpt.SymbolId1  = LV_SYMBOL_DOWN;
    LoginDesc->OperatorOpt.TxtId      = LV_LANG_TXT_ID_NONE;
    LoginDesc->LoginBtn.TxtId         = PHONE_TEXT_ID_LOGIN;
    LoginDesc->KeyFunc                = Interphone_Login_Key_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Login_Create;
    FuncList.OnCreate       = Interphone_Login_OnCreate;
    FuncList.OnDestroy      = Interphone_Common_OnDestroy;
    FuncList.OnRestoreState = Interphone_Login_OnRestore;
    FuncList.OnSaveState    = Interphone_Login_OnSave;

    Nav_Forward(ACT_ID_ANY, ACT_ID_WT_LOGIN, &FuncList, LoginDesc);
    lv_label_set_text(LoginDesc->Label[3].Label, "asr001");
    lv_label_set_text(LoginDesc->Label[5].Label, ". . . . . .");
    UI_Set_User_Num(LoginDesc->OperatorOpt.Button, 50);
    UI_Set_User_Num(LoginDesc->LoginBtn.Button, 51);
}


/**
 * Create grouplist interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_GroupList(VOID)
{
    UI_Normal_List_Only_Desc_t *GroupListDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      i     = 1;
    Interphone_GroupList_Info  *Node = NULL;
    UINT32                     Len;

    GroupListDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(GroupListDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    GroupListDesc->TitleBar.TxtId = LV_LANG_TXT_ID_NONE;

    GroupListDesc->List.ListButtonCnt = 6;

    Len                            = sizeof(UI_Button_Desc_t) * GroupListDesc->List.ListButtonCnt;
    GroupListDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(GroupListDesc->List.ButtonList, 0, Len);

    GroupListDesc->List.ButtonList[0].Valid       = TRUE;
    GroupListDesc->List.ButtonList[0].ButtonIndex = 0xFF;
    GroupListDesc->List.ButtonList[0].SymbolId1   = SYMBOL_INTERPHONE_DIST;
    GroupListDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_FRIENDLIST;
    GroupListDesc->List.ButtonList[0].ReleaseFun  = Interphone_FriendList_Btn_Cb;

    Node = (Interphone_GroupList_Info *)_lv_ll_get_head(Interphone_GroupList);
    while (Node)
    {
        GroupListDesc->List.ButtonList[i].BtnTxt = Hal_Mem_Alloc(GROUP_NAME_LEN + 16);
        snprintf(GroupListDesc->List.ButtonList[i].BtnTxt, GROUP_NAME_LEN + 16, "%s(%d/%d/%d)",
            Node->Name, Node->MemberCnt, Node->OnlineMemberCnt, Node->MsgCnt);
        GroupListDesc->List.ButtonList[i].Valid       = TRUE;
        GroupListDesc->List.ButtonList[i].ButtonIndex = 0xFF;
        GroupListDesc->List.ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        GroupListDesc->List.ButtonList[i].SymbolId1   = SYMBOL_INTERPHONE_DIST;
        GroupListDesc->List.ButtonList[i].SymbolId2   = LV_SYMBOL_VOLUME_MAX;
        GroupListDesc->List.ButtonList[i].ReleaseFun  = Interphone_GroupList_Btn_Cb;
        Node                                          = _lv_ll_get_next(Interphone_GroupList, Node);
        i++;
    }

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_GroupList_Create;
    FuncList.OnSaveState    = Interphone_GroupList_OnSave;
    FuncList.OnRestoreState = Interphone_GroupList_OnRestore;
    FuncList.OnDestroy      = Interphone_List_OnDestroy;
    GroupListDesc->KeyFunc  = Interphone_GroupList_Key_Cb;

    Nav_Forward(ACT_ID_ANY, ACT_ID_WT_GROUP_LIST, &FuncList, GroupListDesc);
    lv_label_set_text(GroupListDesc->TitleBar.Label, "ASRTest(ASR)");
} /* Interphone_Create_GroupList */


/**
 * Create setting interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_Setting(ACTIVITY_ID ScrId)
{
    Nav_Func_List_t                 FuncList;
    UI_Normal_Container_List_Desc_t *pNormalContLstDesc;
    UINT8                           i = 0;

    // Alloc memory for time setting UI display
    pNormalContLstDesc = Hal_Mem_Alloc(sizeof(UI_Normal_Container_List_Desc_t));
    Hal_Mem_Set(pNormalContLstDesc, 0, sizeof(UI_Normal_Container_List_Desc_t));

    pNormalContLstDesc->TitleBar.TxtId      = PHONE_TEXT_ID_SETTINGS;
    pNormalContLstDesc->TitleBar.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalContLstDesc->TitleBar.LabelAlign = LV_ALIGN_IN_TOP_LEFT;

    pNormalContLstDesc->ContList.Index = 1;

    pNormalContLstDesc->ContList.ListContainerCnt = 13;
#if USE_CRANE_CAMERA
    pNormalContLstDesc->ContList.ListContainerCnt++;
    printf("%s: enable camera, num %d\n", __FUNCTION__,
           pNormalContLstDesc->ContList.ListContainerCnt);
#endif
#if USE_LV_INTERPHONE_TEST
    pNormalContLstDesc->ContList.ListContainerCnt++;
    printf("%s: enable test mode, num %d\n", __FUNCTION__,
           pNormalContLstDesc->ContList.ListContainerCnt);
#endif
    pNormalContLstDesc->ContList.ContainerList    = Hal_Mem_Alloc(
        sizeof(UI_Container_Base_Desc_t) * pNormalContLstDesc->ContList.ListContainerCnt);
    Hal_Mem_Set(pNormalContLstDesc->ContList.ContainerList, 0,
        sizeof(UI_Container_Base_Desc_t) * pNormalContLstDesc->ContList.ListContainerCnt);

    pNormalContLstDesc->ContList.ContainerList[0].Label.TxtId    = LV_LANG_TXT_ID_NONE;
    pNormalContLstDesc->ContList.ContainerList[0].Valid          = FALSE;
    pNormalContLstDesc->ContList.ContainerList[0].Choise         = UI_BASE_OBJ_LABEL;
    pNormalContLstDesc->ContList.ContainerList[0].u.Label2.TxtId = LV_LANG_TXT_ID_NONE;

    pNormalContLstDesc->ContList.ContainerList[1].Label.TxtId = PHONE_TEXT_ID_AUTO_LOGIN;
    pNormalContLstDesc->ContList.ContainerList[2].Label.TxtId = PHONE_TEXT_ID_VOICE_BROAD;
    pNormalContLstDesc->ContList.ContainerList[3].Label.TxtId = PHONE_TEXT_ID_START_SPEAK_TONE;
    pNormalContLstDesc->ContList.ContainerList[4].Label.TxtId = PHONE_TEXT_ID_END_SPEAK_TONE;
    pNormalContLstDesc->ContList.ContainerList[5].Label.TxtId = PHONE_TEXT_ID_BUSY_TONE;
    pNormalContLstDesc->ContList.ContainerList[6].Label.TxtId = PHONE_TEXT_ID_8K_ENCODE;
    pNormalContLstDesc->ContList.ContainerList[7].Label.TxtId = PHONE_TEXT_ID_SHOW_SPEED;
    pNormalContLstDesc->ContList.ContainerList[8].Label.TxtId = PHONE_TEXT_ID_SPEAKING_LIGHTSCREEN;
    pNormalContLstDesc->ContList.ContainerList[9].Label.TxtId = PHONE_TEXT_ID_POWER_SAVE;

    for (i = 1; i < 10; i++)
    {
        pNormalContLstDesc->ContList.ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_LEFT;
        pNormalContLstDesc->ContList.ContainerList[i].Label.LabelAlign = LV_ALIGN_IN_LEFT_MID;
        pNormalContLstDesc->ContList.ContainerList[i].Valid            = TRUE;
        pNormalContLstDesc->ContList.ContainerList[i].Choise           = UI_BASE_OBJ_SW;
        pNormalContLstDesc->ContList.ContainerList[i].u.Sw.State       = TRUE;
        pNormalContLstDesc->ContList.ContainerList[i].ReleaseFunc      = InterPhone_Setting_Btn_Cb;
    }

    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtId    = PHONE_TEXT_ID_BACKLIGHT;
    pNormalContLstDesc->ContList.ContainerList[i].Valid          = TRUE;
    pNormalContLstDesc->ContList.ContainerList[i].Choise         = UI_BASE_OBJ_BAR;
    pNormalContLstDesc->ContList.ContainerList[i].u.Bar.Range    = 5;
    pNormalContLstDesc->ContList.ContainerList[i].u.Bar.Value    = BackLight;
    i++;

    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtId       = PHONE_TEXT_ID_VERSION_UPDATE;
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtAlign    = LV_LABEL_ALIGN_LEFT;
    pNormalContLstDesc->ContList.ContainerList[i].Label.LabelAlign  = LV_ALIGN_IN_LEFT_MID;
    pNormalContLstDesc->ContList.ContainerList[i].Choise            = UI_BASE_OBJ_LABEL;
    pNormalContLstDesc->ContList.ContainerList[i].Valid             = TRUE;
    pNormalContLstDesc->ContList.ContainerList[i].u.Label2.TxtId    = LV_LANG_TXT_ID_NONE;
    pNormalContLstDesc->ContList.ContainerList[i].u.Label2.TxtAlign = LV_LABEL_ALIGN_RIGHT;
    i++;

#if USE_LV_INTERPHONE_TEST
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_TEST_MODE;
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Label.LabelAlign = LV_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
    pNormalContLstDesc->ContList.ContainerList[i].Valid            = TRUE;
    pNormalContLstDesc->ContList.ContainerList[i].ReleaseFunc      = InterPhone_Setting_Test_Btn_Cb;
    i++;
#endif

#if USE_CRANE_CAMERA
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_CAMERA_PREVIEW;
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Label.LabelAlign = LV_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
    pNormalContLstDesc->ContList.ContainerList[i].Valid            = TRUE;
    pNormalContLstDesc->ContList.ContainerList[i].ReleaseFunc      = InterPhone_Setting_Camera_Preview_Btn_Cb;
    i++;
#endif

    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtId      = PHONE_TEXT_ID_QUIT;
    pNormalContLstDesc->ContList.ContainerList[i].Label.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Label.LabelAlign = LV_ALIGN_CENTER;
    pNormalContLstDesc->ContList.ContainerList[i].Choise           = UI_BASE_OBJ_NULL;
    pNormalContLstDesc->ContList.ContainerList[i].Valid            = TRUE;
    pNormalContLstDesc->ContList.ContainerList[i].ReleaseFunc      = InterPhone_Setting_Quit_Btn_Cb;
    i++;

    pNormalContLstDesc->KeyFunc = InterPhone_Settings_KeyCb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_Setting_Create;
    FuncList.OnRestoreState = Interphone_Setting_OnRestore;
    FuncList.OnDestroy      = Interphone_Setting_OnDestroy;
    FuncList.OnSaveState    = Interphone_Setting_OnSaveState;

    Nav_Forward(ScrId, ACT_ID_WT_SETTING, &FuncList, pNormalContLstDesc);

    lv_label_set_text(pNormalContLstDesc->ContList.ContainerList[0].Label.Label,"ASR Test1");
    lv_label_set_text(pNormalContLstDesc->ContList.ContainerList[0].u.Label2.Label, "Acc:asr001");
    lv_label_set_text(pNormalContLstDesc->ContList.ContainerList[11].u.Label2.Label, "1.0.0.64");
} /* Interphone_Create_Setting */


/**
 * Create groupmember list interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_GroupMemberList(UINT8 Index)
{
    UI_Normal_List_Only_Desc_t *GroupMemListDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      i     = 0;
    UINT8                      j     = 1;
    Interphone_GroupList_Info  *Node = NULL;
    UINT32                     Len;
    INT8                       TitleBuf[GROUP_NAME_LEN + 16];

    GroupMemListDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(
        sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(GroupMemListDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));

    Node = (Interphone_GroupList_Info *)_lv_ll_get_head(Interphone_GroupList);
    while (j != Index)
    {
        Node = _lv_ll_get_next(Interphone_GroupList, Node);
        j++;
    }
    GroupMemListDesc->List.ListButtonCnt = Node->MemberCnt;
    printf("group member index=%d Cnt = %d\n",Index,GroupMemListDesc->List.ListButtonCnt);

    Len = sizeof(UI_Button_Desc_t) *
          GroupMemListDesc->List.ListButtonCnt;
    GroupMemListDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(GroupMemListDesc->List.ButtonList, 0, Len);

    for (i = 0; i < GroupMemListDesc->List.ListButtonCnt; i++)
    {
        GroupMemListDesc->List.ButtonList[i].BtnTxt = Hal_Mem_Alloc(GROUPMEMBER_NAME_LEN);
        snprintf(GroupMemListDesc->List.ButtonList[i].BtnTxt, GROUP_NAME_LEN, "%s",
            Node->Member[i].MemberName);
        GroupMemListDesc->List.ButtonList[i].Valid       = TRUE;
        GroupMemListDesc->List.ButtonList[i].ButtonIndex = 0xFF;
        GroupMemListDesc->List.ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        GroupMemListDesc->List.ButtonList[i].SymbolId1   = SYMBOL_INTERPHONE_ADD_NAME;
        GroupMemListDesc->List.ButtonList[i].SymbolId2   = SYMBOL_INTERPHONE_UNCHECK;
        GroupMemListDesc->List.ButtonList[i].ReleaseFun  = Interphone_GroupMemberList_Btn_Cb;
    }

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_GroupList_Create;
    FuncList.OnDestroy = Interphone_List_OnDestroy;

    GroupMemListDesc->KeyFunc = Interphone_GroupMember_Key_Cb;
    Nav_Forward(ACT_ID_WT_GROUP_LIST, ACT_ID_WT_GROUPMEMBER_LIST, &FuncList, GroupMemListDesc);
    snprintf(TitleBuf, GROUP_NAME_LEN + 16, "ASR Test(%s)",Node->Name);
    lv_label_set_text(GroupMemListDesc->TitleBar.Label, TitleBuf);

    for (i = 0; i < GroupMemListDesc->List.ListButtonCnt; i++)
    {
        if (Node->Member[i].Online == FALSE)
        {
            lv_obj_add_style(lv_obj_get_child_back(GroupMemListDesc->List.ButtonList[i].Button,
                                                   NULL), LV_IMG_PART_MAIN, &img_light);
            lv_obj_set_style_local_image_recolor(lv_obj_get_child_back(GroupMemListDesc->List.ButtonList[i].Button,
                                                                       NULL), LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
        }
    }
} /* Interphone_Create_GroupMemberList */


/**
 * Create friendlist interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_FriendList(VOID)
{
    UI_Normal_List_Only_Desc_t *FriendListDesc;
    Nav_Func_List_t            FuncList;
    UINT8                      i     = 0;
    Interphone_FriendList_Info *Node = NULL;
    UINT32                     Len;

    FriendListDesc =
        (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(FriendListDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));
    Node = (Interphone_FriendList_Info *)_lv_ll_get_head(Interphone_FriendList);

    FriendListDesc->List.ListButtonCnt = 5;

    Len                             = sizeof(UI_Button_Desc_t) * FriendListDesc->List.ListButtonCnt;
    FriendListDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(FriendListDesc->List.ButtonList, 0, Len);

    Node = (Interphone_FriendList_Info *)_lv_ll_get_head(Interphone_FriendList);
    for (i = 0; i < FriendListDesc->List.ListButtonCnt; i++)
    {
        FriendListDesc->List.ButtonList[i].BtnTxt = Hal_Mem_Alloc(GROUPMEMBER_NAME_LEN);
        snprintf(FriendListDesc->List.ButtonList[i].BtnTxt, GROUP_NAME_LEN, "%s", Node->FriendName);
        FriendListDesc->List.ButtonList[i].Valid       = TRUE;
        FriendListDesc->List.ButtonList[i].ButtonIndex = 0xFF;
        FriendListDesc->List.ButtonList[i].TxtId       = LV_LANG_TXT_ID_NONE;
        FriendListDesc->List.ButtonList[i].SymbolId1   = SYMBOL_INTERPHONE_ADD_NAME;
        FriendListDesc->List.ButtonList[i].SymbolId2   = SYMBOL_INTERPHONE_UNCHECK;
        FriendListDesc->List.ButtonList[i].ReleaseFun  = Interphone_GroupMemberList_Btn_Cb;
        Node                                           =
            _lv_ll_get_next(Interphone_FriendList, Node);
    }

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_GroupList_Create;
    FuncList.OnRestoreState = Interphone_FriendList_OnRestore;
    FuncList.OnDestroy      = Interphone_List_OnDestroy;

    FriendListDesc->KeyFunc = InterPhone_Friendlist_KeyCb;
    Nav_Forward(ACT_ID_WT_GROUP_LIST, ACT_ID_WT_FRIEND_LIST, &FuncList, FriendListDesc);
    lv_label_set_text(FriendListDesc->TitleBar.Label, "ASRTest(Friends)");

    Node                 = (Interphone_FriendList_Info *)_lv_ll_get_head(Interphone_FriendList);
    for (i = 0; i < FriendListDesc->List.ListButtonCnt; i++)
    {
        if (Node->Online == FALSE)
        {
            lv_obj_add_style(lv_obj_get_child_back(FriendListDesc->List.ButtonList[i].Button,
                                                   NULL), LV_IMG_PART_MAIN, &img_light);
            lv_obj_set_style_local_image_recolor(lv_obj_get_child_back(FriendListDesc->List.ButtonList[i].Button,
                                                                       NULL), LV_IMG_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GRAY);
        }
        Node = _lv_ll_get_next(Interphone_FriendList, Node);
    }
} /* Interphone_Create_FriendList */


/**
 * Create quit option interface
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_QuitOpt(VOID)
{
    UI_QuitOpt_Desc_t *QuitOptDesc;
    Nav_Func_List_t   FuncList;

    QuitOptDesc = (UI_QuitOpt_Desc_t *)Hal_Mem_Alloc(sizeof(UI_QuitOpt_Desc_t));
    Hal_Mem_Set(QuitOptDesc, 0, sizeof(UI_QuitOpt_Desc_t));

    QuitOptDesc->Img.Img = LV_SYMBOL_WARNING;

    QuitOptDesc->Label1.TxtId    = PHONE_TEXT_ID_QUIT;
    QuitOptDesc->Label1.TxtAlign = LV_LABEL_ALIGN_LEFT;
    QuitOptDesc->Label2.TxtId    = PHONE_TEXT_ID_CONFIRM_OPRATION;
    QuitOptDesc->Label2.TxtAlign = LV_LABEL_ALIGN_LEFT;

    QuitOptDesc->QuitBtn.Valid        = TRUE;
    QuitOptDesc->QuitBtn.TxtId        = PHONE_TEXT_ID_QUIT;
    QuitOptDesc->QuitBtn.ReleaseFun   = Interphone_QuitOpt_Quit_Btn_Cb;
    QuitOptDesc->LogoutBtn.Valid      = TRUE;
    QuitOptDesc->LogoutBtn.TxtId      = PHONE_TEXT_ID_LOGOUT;
    QuitOptDesc->LogoutBtn.ReleaseFun = Interphone_QuitOpt_Logout_Btn_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow    = UI_Quit_Option_Create;
    FuncList.OnDestroy = Interphone_Common_OnDestroy;

    QuitOptDesc->KeyFunc = Interphone_QuitOpt_KeyCb;

    Nav_Forward(ACT_ID_WT_SETTING, ACT_ID_WT_QUIT_OPT, &FuncList, QuitOptDesc);
}


#if USE_CRANE_CAMERA
/**
 * Create camera interface
 * param (in) SrcId:ACTIVITY_ID
 * return  VOID
 */
VOID Interphone_Create_Camera(VOID)
{
    Nav_Func_List_t     FuncList = {};
    UI_Camera_Desc_t    *Desc;

    Desc = Hal_Mem_Alloc(sizeof(UI_Camera_Desc_t));
    Hal_Mem_Set(Desc, 0, sizeof(UI_Camera_Desc_t));

    Desc->KeyFunc = Interphone_Camera_Key_Cb;

    Desc->Btn.Valid = TRUE;
    Desc->Btn.TxtId = PHONE_TEXT_ID_BACK;

    FuncList.OnShow         = UI_Camera_Create;
    FuncList.OnCreate       = Interphone_Camera_OnCreate;
    FuncList.OnRestoreState = Interphone_Camera_OnCreate;
    FuncList.OnSaveState    = Interphone_Camera_OnDestroy;
    FuncList.OnDestroy      = Interphone_Camera_OnDestroy;

    Nav_Forward(ACT_ID_ANY, ACT_ID_CAMERA, &FuncList, Desc);
}
#endif


/**
 * Create poweroff interface
 * param (in) SrcId:ACTIVITY_ID
 * return  VOID
 */
VOID Interphone_Create_PowerOff(ACTIVITY_ID SrcId)
{
    UI_Normal_List_Only_Desc_t *PowerOffDesc;
    Nav_Func_List_t            FuncList;
    UINT32                     Len;

    PowerOffDesc = (UI_Normal_List_Only_Desc_t *)Hal_Mem_Alloc(sizeof(UI_Normal_List_Only_Desc_t));
    Hal_Mem_Set(PowerOffDesc, 0, sizeof(UI_Normal_List_Only_Desc_t));
    PowerOffDesc->List.ListButtonCnt = 2;

    Len                           = sizeof(UI_Button_Desc_t) * PowerOffDesc->List.ListButtonCnt;
    PowerOffDesc->List.ButtonList = (UI_Button_Desc_t *)Hal_Mem_Alloc(Len);
    Hal_Mem_Set(PowerOffDesc->List.ButtonList, 0, Len);

    PowerOffDesc->TitleBar.TxtId = LV_LANG_TXT_ID_NONE;

    PowerOffDesc->List.ButtonList[0].Valid       = TRUE;
    PowerOffDesc->List.ButtonList[0].ButtonIndex = 0xFF;
    PowerOffDesc->List.ButtonList[0].TxtId       = PHONE_TEXT_ID_POWEROFF;
    PowerOffDesc->List.ButtonList[0].SymbolId1   = LV_SYMBOL_POWER;
    PowerOffDesc->List.ButtonList[0].ReleaseFun  = Interphone_PowerOff_Btn_Cb;

    PowerOffDesc->List.ButtonList[1].Valid       = TRUE;
    PowerOffDesc->List.ButtonList[1].ButtonIndex = 0xFF;
    PowerOffDesc->List.ButtonList[1].TxtId       = PHONE_TEXT_ID_RESTART;
    PowerOffDesc->List.ButtonList[1].SymbolId1   = LV_SYMBOL_REFRESH;
    PowerOffDesc->List.ButtonList[1].ReleaseFun  = Interphone_Restart_Btn_Cb;

    Hal_Mem_Set(&FuncList, 0, sizeof(Nav_Func_List_t));
    FuncList.OnShow         = UI_PowerOff_Create;
    FuncList.OnDestroy      = Interphone_List_OnDestroy;
    FuncList.OnRestoreState = Interphone_Common_OnDestroy;

    PowerOffDesc->KeyFunc = Interphone_PowerOff_KeyCb;

    Nav_Forward(SrcId, ACT_ID_WT_POWEROFF, &FuncList, PowerOffDesc);
    g_PoweroffLongPress = TRUE;
}


/**
 * Create Status bar
 * param (in) VOID
 * return  VOID
 */
VOID Interphone_Create_Status_Bar(VOID)
{
    UI_Interphone_Status_Bar_Desc_t StaBarDesc;

    Hal_Mem_Set(&StaBarDesc, 0, sizeof(UI_Interphone_Status_Bar_Desc_t));

    StaBarDesc.TimeLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    StaBarDesc.TimeLabel.TxtAlign   = LV_LABEL_ALIGN_RIGHT;

    StaBarDesc.BatteryLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    StaBarDesc.BatteryLabel.TxtAlign   = LV_LABEL_ALIGN_RIGHT;
    if (Hal_Charger_Get_Status() == HAL_CHG_DISCONNECTED)
    {
        UINT8 BatSta = Framework_Get_Battery_Level(Hal_Battery_Get_Status());
        StaBarDesc.BatteryLabel.SymbolId = Framework_Get_Battery_Symbol(BatSta);
    }
    else
    {
        StaBarDesc.BatteryLabel.SymbolId = LV_SYMBOL_CHARGE;
    }

    StaBarDesc.SignalImg.ImgSrc =
        Framework_Signal_Bar_To_Symbol(MMI_Modem_Get_Signal_Bar_Req(MMI_MODEM_SIM_1));

    StaBarDesc.StanLabel.TxtId    = LV_LANG_TXT_ID_NONE;
    StaBarDesc.StanLabel.TxtAlign = LV_LABEL_ALIGN_RIGHT;
    if (FALSE == g_SimSta)
    {
        StaBarDesc.StanLabel.ImgSrc = SYMBOL_NO_SIM_CARD;
    }

    StaBarDesc.VolumeLabel.TxtId    = LV_LANG_TXT_ID_NONE;
    StaBarDesc.VolumeLabel.TxtAlign = LV_LABEL_ALIGN_RIGHT;
    if (SliderVolume == 0)
    {
        StaBarDesc.VolumeLabel.SymbolId = LV_SYMBOL_MUTE;
    }

    StaBarDesc.OnlineStateLabel.TxtId      = LV_LANG_TXT_ID_NONE;
    StaBarDesc.OnlineStateLabel.TxtAlign   = LV_LABEL_ALIGN_CENTER;
    StaBarDesc.OnlineStateLabel.LabelAlign = LV_ALIGN_CENTER;

    UI_Interphone_StatusBar_Create(&StaBarDesc);

    g_Interphone_StatusBar.Label_Battery = StaBarDesc.BatteryLabel.Label;
    g_Interphone_StatusBar.Label_Volume  = StaBarDesc.VolumeLabel.Label;
    g_Interphone_StatusBar.Label_Online  = StaBarDesc.OnlineStateLabel.Label;
    g_Interphone_StatusBar.Img_Signal    = StaBarDesc.SignalImg.Img;
    g_Interphone_StatusBar.Label_Time    = StaBarDesc.TimeLabel.Label;
    g_Interphone_StatusBar.Label_Stan    = StaBarDesc.StanLabel.Label;
    g_Interphone_StatusBar.Img_Stan      = StaBarDesc.StanLabel.Img;

    Interphone_Set_StatusBar_Online_Hidden(FALSE, FALSE, 3000);

    Hal_Timer_Start(1000, Interphone_Status_Update_Timer_Cb, NULL, TRUE);
} /* Interphone_Create_Status_Bar */


VOID Interphone_GroupList_Init(VOID)
{
    if (Interphone_GroupList == NULL)
    {
        Interphone_GroupList = lv_mem_alloc(sizeof(lv_ll_t));
        memset(Interphone_GroupList, 0, sizeof(lv_ll_t));
        _lv_ll_init(Interphone_GroupList, sizeof(Interphone_GroupList_Info));
    }
// for test
    Interphone_GroupList_Info *Node = NULL;
    UINT8                     i,j;
    for (i = 0; i < 5; i++)
    {
        Node = (Interphone_GroupList_Info *)_lv_ll_ins_tail(Interphone_GroupList);
        snprintf(Node->Name, GROUP_NAME_LEN, "%s", TestGroup[i].Name);
        Node->MemberCnt       = TestGroup[i].MemberCnt;
        Node->OnlineMemberCnt = TestGroup[i].OnlineMemberCnt;
        Node->MsgCnt          = TestGroup[i].MsgCnt;
        Node->Member          =
            Hal_Mem_Alloc(Node->MemberCnt * sizeof(Interphone_GroupMember_Info));
        for (j = 0; j < Node->MemberCnt; j++)
        {
            snprintf(Node->Member[j].MemberName, GROUPMEMBER_NAME_LEN, "%s",
                TestMember[j].MemberName);
            Node->Member[j].Online = TestMember[j].Online;
        }
    }
}


VOID Interphone_FriendList_Init(VOID)
{
    if (Interphone_FriendList == NULL)
    {
        Interphone_FriendList = lv_mem_alloc(sizeof(lv_ll_t));
        memset(Interphone_FriendList, 0, sizeof(lv_ll_t));
        _lv_ll_init(Interphone_FriendList, sizeof(Interphone_FriendList_Info));
    }
    // for test
    Interphone_FriendList_Info *Node = NULL;
    UINT8                      i;
    for (i = 0; i < 5; i++)
    {
        Node = (Interphone_FriendList_Info *)_lv_ll_ins_tail(Interphone_FriendList);
        snprintf(Node->FriendName, GROUP_NAME_LEN, "%s", TestFriend[i].FriendName);
        Node->Online = TestFriend[i].Online;
    }
}

#if USE_LV_INTERPHONE_TEST

VOID Phone_Modem_Call_Response_Clip(MMI_MODEM_SIM_ID SimId, INT32 Index,
                                    MMI_Modem_Call_Response_Clip_t *Clip)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);

    If_Setting_Play_Tone_t *PlayToneReq =
        (If_Setting_Play_Tone_t *)Hal_Mem_Alloc(sizeof(If_Setting_Play_Tone_t));
    PlayToneReq->SimId    = MMI_MODEM_SIM_1;
    PlayToneReq->ToneType = IF_SETTING_TONS_TYPE_CALL;
    PlayToneReq->SpecToneIndex = 0;
    PlayToneReq->PlayCtrl = IF_SETTING_PLAY_TONS_START;
    Setting_Play_Tone_Req(PlayToneReq);

    Interphone_Test_Call_Main(Clip->number, TRUE, Index);

    Hal_Mem_Free(Clip->number);
    Hal_Mem_Free(Clip);
}


VOID Phone_Modem_Call_Response_Ring(MMI_MODEM_SIM_ID SimId, INT32 Index)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);
}


VOID Phone_Modem_Call_Response_Dial(UINT8 Is_Ok)
{
    if (Is_Ok)
    {
        // CME ERROR
        UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
        Interphone_Test_Set_Label_Txt_Str(&Desc->ContList.ContainerList[0].Label, "CME ERROR");
        lv_label_set_text_id(lv_obj_get_child_back(Desc->ButtonBar.ButtonR.Button, NULL),
                             PHONE_TEXT_ID_BACK);
        Desc->ButtonBar.ButtonR.ReleaseFun = Interphone_Test_Call_main_Back_Cb;
        Hal_Set_Voice_Call_Status(VOICE_CALL_END);
    }
}


VOID Phone_Modem_Call_Response_Alerting(MMI_MODEM_SIM_ID SimId, INT32 Index)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    if (NULL == Desc)
    {
        printf("%s: warning, no call ui\n", __FUNCTION__);
        return;
    }
    Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[0].Label, PHONE_TEXT_ID_RINGING);
    Interphone_Test_Call_Spk_Ctrl(FALSE);
}


VOID Phone_Modem_Call_Response_Connect(MMI_MODEM_SIM_ID SimId, INT32 Index)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    if (NULL == Desc)
    {
        printf("%s: warning, no call ui\n", __FUNCTION__);
        return;
    }

    if (PHONE_TEXT_ID_CONNECTED == Desc->ContList.ContainerList[0].Label.TxtId)
    {
        printf("%s: warning, connect msg has been received\n", __FUNCTION__);
        return;
    }

    Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[0].Label, PHONE_TEXT_ID_CONNECTED);

    Interphone_Test_Call_Info_t *Info = UI_Get_User_Ptr(Desc->TitleBar.Label);
    if (Info->IsMt)
    {
        Interphone_Test_Stop_Ring();
        Interphone_Test_Call_Spk_Ctrl(FALSE);
    }

    lv_obj_t *Label = Desc->ContList.ContainerList[1].Label.Label;
    UI_Set_User_Num(Label, UI_Get_Timestamp_In_Second());

    lv_anim_t Anim;
    lv_anim_path_t Path;

    lv_anim_path_init(&Path);
    lv_anim_path_set_cb(&Path, lv_anim_path_step);

    lv_anim_init(&Anim);
    lv_anim_set_var(&Anim, Label);
    lv_anim_set_start_cb(&Anim, (lv_anim_ready_cb_t)Interphone_Test_Anim_Fp_Connected);
    lv_anim_set_path(&Anim, &Path);
    lv_anim_set_time(&Anim, 1);
    lv_anim_set_playback_time(&Anim, 0);
    lv_anim_set_playback_delay(&Anim, 0);
    lv_anim_set_repeat_count(&Anim, LV_ANIM_REPEAT_INFINITE);
    lv_anim_set_repeat_delay(&Anim, 1000);

    lv_anim_start(&Anim);
}


VOID Phone_Modem_Call_Response_No_Carrier(MMI_MODEM_SIM_ID SimId, INT32 Index, UINT8 isNoCarrier)
{
    printf("%s: SimId %d, Index %d, isNoCarrier %d\n", __FUNCTION__, SimId, Index, isNoCarrier);

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    if (NULL == Desc)
    {
        printf("%s: warning, no call ui\n", __FUNCTION__);
        return;
    }

    lv_obj_t *Label = Desc->ContList.ContainerList[1].Label.Label;
    lv_anim_del(Label, NULL);

    Interphone_Test_Stop_Ring();
    Hal_Set_Voice_Call_Status(VOICE_CALL_END);
    Interphone_Test_Call_Spk_Ctrl(TRUE);       // turn on the speaker

    if (g_ReservedDesc) {
        printf("%s: handle g_ReservedDesc\n", __FUNCTION__);
        Nav_Func_List_t FuncList = {};
        FuncList.OnShow    = UI_Interphone_Test_Create;
        FuncList.OnDestroy = Interphone_Test_Main_Com_OnDestroy;
        Nav_Backward_And_Forward(ACT_ID_ANY, ACT_ID_MENU, ACT_ID_MESSAGES_INBOX, &FuncList, g_ReservedDesc);
        g_ReservedDesc = NULL;
    } else {
        Nav_Back(ACT_ID_ANY);
    }
}


VOID Phone_Modem_Call_Response_Originating(MMI_MODEM_SIM_ID SimId, INT32 Index)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);
    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_CALL_MAIN);
    Interphone_Test_Call_Info_t *Info = UI_Get_User_Ptr(Desc->TitleBar.Label);
    Info->CallIndex = Index;
}


VOID Phone_Modem_Call_Response_Disconnect(MMI_MODEM_SIM_ID SimId, INT32 Index)
{
    printf("%s: SimId %d, Index %d\n", __FUNCTION__, SimId, Index);
}

VOID Phone_Modem_Send_Sms_Cnf_Handler(MMI_Modem_Send_Sms_Cnf_t *pSendSmsCnf)
{
    MMI_MODEM_SMS_RESULT_TYPE Result = pSendSmsCnf->Result;
    Hal_Mem_Free(pSendSmsCnf);

    UI_Normal_Container_List_Desc_t *Desc = Nav_Get_Param(ACT_ID_MESSAGES_SENDING_MESSAGE);
    printf("%s: Result %d, Desc %p\n", __FUNCTION__, Result, Desc);

    if (NULL == Desc) return;

    if (MMI_MODEM_SMS_SUCCESS == Result)
    {
        Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[1].Label,
                                         PHONE_TEXT_ID_SEND_SUCCESS);
    }
    else
    {
        Interphone_Test_Set_Label_Txt_Id(&Desc->ContList.ContainerList[1].Label,
                                         PHONE_TEXT_ID_SEND_FAILED);
    }
}

VOID Phone_Modem_Sms_Status_Rep_Ind(MMI_Modem_Response_Sms_Status_Rep_Ind_t *pRepNewStsRep)
{
    printf("%s\n", __FUNCTION__);
    Hal_Mem_Free(pRepNewStsRep->pSmsStatusRep);
    Hal_Mem_Free(pRepNewStsRep);
}

VOID Phone_Modem_Rep_New_Sms_Ind(MMI_Modem_Report_New_Sms_Ind_t *pRepNewSms)
{
    printf("%s\n", __FUNCTION__);
    MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *pReadSmsReq;

    pReadSmsReq = (MMI_Modem_Read_Sms_Detail_On_Sim_Req_t *)Hal_Mem_Alloc(sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    Hal_Mem_Set(pReadSmsReq, 0, sizeof(MMI_Modem_Read_Sms_Detail_On_Sim_Req_t));

    pReadSmsReq->MsgIndex = pRepNewSms->MsgContentInfo.MsgIndex;

    pReadSmsReq->SimId = pRepNewSms->MsgContentInfo.SimId;
    MMI_Modem_Read_Sms_Detail_On_Sim_Req(pReadSmsReq);

    Hal_Mem_Free(pRepNewSms);
}

VOID Phone_Modem_Read_Sms_Detail_On_Sim_Cnf_Handler(MMI_Modem_Read_Sms_Detail_On_Sim_Cnf_t *pReadSmsCnf)
{
    INT8 *Number   = NULL;
    INT8 *Time     = NULL;
    INT8 *pSmsText = NULL;

    if (MMI_MODEM_SMS_FAIL == pReadSmsCnf->Result)
    {
        printf("%s: warning, read sms fail\n", __FUNCTION__);
        return;
    }

    // decode sms,get smstext and number
#if MMI_MODEM_SMS_STORE_IN_FILE != 0
    MMI_Modem_Sms_File_DecodeSmsPdu(pReadSmsCnf->pSmsPdu, &Number, &Time, &pSmsText);
#endif
    printf("%s: number %s, time %s\n", __FUNCTION__, Number, Time);
    Interphone_Test_Sms_Main(Number, pSmsText, FALSE);
    if (Number)
    {
        Hal_Mem_Free(Number);
    }
    if (Time)
    {
        Hal_Mem_Free(Time);
    }
    if (pSmsText)
    {
        Hal_Mem_Free(pSmsText);
    }

    Hal_Mem_Free(pReadSmsCnf->pSmsPdu);
    Hal_Mem_Free(pReadSmsCnf);
}

BOOL Interphone_Test_Is_Call_Present(VOID)
{
    if (Nav_Get_Param(ACT_ID_CALL_MAIN))
    {
        return(TRUE);
    }
    return(FALSE);
}
#endif

#endif /*USE_LV_INTERPHONE_DEMO*/
